//以前没分类过 现在该分类一下了
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <queue>
#include <cstring>
#include <string>
#include <limits.h>
#include <string.h>
#include <vector>
#include <map>
#define LL long long
#define INF 2100000000
#define fi first
#define se second
#define lowbit(x) (x&(-x))
#define eps 5e-7
using namespace std;
const int maxn=(int)1e6 +10;
const int maxm=(int)1e4+10;
const LL MOD=(LL)1e9+7;
int next1[maxm];
void kmppre(char x[])
{
int i,j;
j=next1[0]=-1; //next[i]表示在第i个字符失配后,
//模式串中0->next[i]处仍为匹配状态
i=0;
while(x[i])
{
while(j!=-1&&x[i]!=x[j]) j=next1[j];
next1[++i]=++j;
}
}
int kmpcount(char x[],char y[]){
int i,j,ans=0;
kmppre(x);
i=j=0;
while(y[i]){
while(j!=-1&&y[i]!=x[j])j=next1[j];
i++;j++;
if(!x[j]){
ans++;j=next1[j];
}
}
return ans;
}
char s1[maxm],s2[maxn];
int main()
{
#ifdef shuaishuai
freopen("C:\Users\hasee\Desktop\a.txt","r",stdin);
//freopen("C:\Users\hasee\Desktop\b.txt","w",stdout);
#endif
int t;
scanf("%d
", &t);
while(t--){
gets(s1);gets(s2);
printf("%d
",kmpcount(s1,s2));
}
return 0;
}