/* ****GT_18**** */
//Motivational Source->FUHPD
#include<bits/stdc++.h>
#define MIN(a,b,c) min(min(a,b),c)
#define MAX(a,b,c) max(max(a,b),c)
#define ll long long
#define itr vector<ll int>::iterator
#define pb push_back
#define mp make_pair
#define pii pair<ll int,ll int>
#define vi vector<ll int>
#define all(a) (a).begin(),(a).end()
#define F first
#define S second
#define sz(x) (ll int)x.size()
#define hell 1000000007
#define endl '\n'
#define rep(i,a,b) for(ll int i=a;i<b;i++)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
using namespace std;
vi cal_lcs(string k)
{
vi f(sz(k)+1);
f[0]=0;
f[1]=0;
rep(i,2,sz(k)+1)
{
int j=f[i-1];
while(1)
{
if(k[j]==k[i-1])
{
f[i]=j+1;
break;
}
if(j==0)
{
f[i]=0;
break;
}
j=f[j];
}
}
return f;
}
void KMP(string a,string b)
{
vi f=cal_lcs(a);
int i=0,j=0,fl=0;
while(1)
{
if(j==sz(b))
break;
if(b[j]==a[i])
{
i++;
j++;
if(i==sz(a))
{
fl=1;
cout<<j-sz(a)<<endl;
}
}
else if(i) i=f[i];
else j++;
}
if(!fl)cout<<endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int TESTS=1;
// cin>>TESTS;
while(cin>>TESTS)
{
string a,b;
cin>>a>>b;
KMP(a,b);
}
return 0;
}
LyogKioqKkdUXzE4KioqKiAqLwovL01vdGl2YXRpb25hbCBTb3VyY2UtPkZVSFBECgojaW5jbHVkZTxiaXRzL3N0ZGMrKy5oPgojZGVmaW5lCU1JTihhLGIsYykJbWluKG1pbihhLGIpLGMpCiNkZWZpbmUJTUFYKGEsYixjKQltYXgobWF4KGEsYiksYykKI2RlZmluZSBsbCAgICAgICAgICBsb25nIGxvbmcKI2RlZmluZSBpdHIgICAgICAgICB2ZWN0b3I8bGwgaW50Pjo6aXRlcmF0b3IKI2RlZmluZSBwYiAgICAgICAgICBwdXNoX2JhY2sKI2RlZmluZSBtcCAgICA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