#include<bits/stdc++.h>
using namespace std;
int f[1005][1005];
int main()
{
int n;
cin>>n;
while(n--)
{
int la,lb,i,j;
char a[1005],b[1005];
cin>>a>>b;
la=strlen(a);
lb=strlen(b);
for(i=0;i<=la;i++)
{
for(j=0;j<=lb;j++)
{
if(i==0)
{
f[i][j]=j;
continue;
}
if(j==0)
{
f[i][j]=i;
continue;
}
if(a[i-1]==b