#include <iostream>
#include <cctype>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#define inf 0x3f3f3f3f
#define LL long long
#define maxn 1000005
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forx(i, a, b) for(int i = b; i >= a; i--)
#define Testin freopen("ztest.txt", "r", stdin)
#define Ansout freopen("zans.txt", "w", stdout)
using namespace std;
int nex[maxn];
void solve(){
string str, pat;
cin >> pat >> str;
nex[0] = -1;
int k = -1, t = 0;
while(t < str.size()){
if(k == -1 || str[k] == str[t]){
++t; ++k;
nex[t] = k;
}
else k = nex[k];
}
int i = 0;
t = 0;
int ans = 0;
while(i < str.size()){
if(t == -1 || str[i] == pat[t]){
++i; ++t;
}
else{
t = nex[t];
}
if(t == pat.size()){
ans ++;
t = nex[t];
}
}
printf("%d\n",ans);
}
int main(){
//Testin;
int n;
scanf("%d", &n);
For(i, 1, n){
solve();
}
return 0;
}