#include<stdio.h>
#include<string.h>
char
s[11000],t[1100000];
int
next[11000];
void
getkmp(
int
len) {
int
j,k;
next[0]=-1;
j=0;k=-1;
while
(j<len)
{
if
(k==-1||s[k]==s[j])
{
j++;k++;
if
(s[j]!=s[k])
next[j]=k;
else
next[j]=next[k];
}
else
k=next[k];
}
return
;
}
int
kmp(
int
lens,
int
lent) {
int
i,j,k=0;
i=j=0;
while
(i<lent)
{
if
(t[i]==s[j])
{
i++;j++;
}
else
{
if
(next[j]!=-1)
j=next[j];
else
{
j=0;i++;
}
}
if
(j==lens)
k++;
}
return
k;
}
int
main() {
int
tt,lens,lent,i;
scanf
(
"%d"
,&tt);
while
(tt--)
{
scanf
(
"%s"
,s);
scanf
(
"%s"
,t);
lens=
strlen
(s);
lent=
strlen
(t);
getkmp(lens);
printf
(
"%d
"
,kmp(lens,lent));
}
return
0;
}