#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 ;//关键点是他会把next[len]的值求出来即为本字符串中的相同数即k的值
}
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==lens时肯定会执行这一步开始比较第k+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\n",kmp(lens,lent));
    }
    return 0;
}