# include<stdio.h>
# include<string.h>
int next[15];
char a[15],b[1005];
void getnext(int len)
{
int k,j;
j=0;
k=-1;
next[0]=-1;
while(j<len)
{
if(k==-1||a[j]==a[k])
{
j++;
k++;
next[j]=k;
}
else
k=next[k];
}
}
int kmp(int len1,int len2)
{
int i=0,j=0,count=0;
while(i<len1)
{
if(j==-1||b[i]==a[j])
{
i++;
j++;
if(j==len2)
{
count++;
}
}
else
j=next[j];
}
return count;
}
int main()
{
int n,s,len1,len2;
scanf("%d",&n);
while(n--)
{
scanf("%s%s",a,b);
len1=strlen(a);
len2=strlen(b);
getnext(len1);
s=kmp(len2,len1);
printf("%d\n",s);
}
return 0;
}