#include<bits/stdc++.h>
using namespace std;

typedef long long ll ;
typedef vector<ll> vi;
typedef vector< pair<ll,ll> > vii;
#define pb(a)         push_back(a)
#define for0(i,n)        for(ll i=0;i<n;i++)
#define for1(i,n)        for(ll i=1;i<=n;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define en              "\n"
#define Ip ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define f(s) cout<<fixed<<setprecision(2)<<s;
#define gp " "
#define W  int t; scanf("%d", &t); for(int q=1; q<=t; q++)
ll i,j,t,x,y,n;
ll mod=1e9 +7;


int main()
{
   W{
   string a,b;ll ar[25][25]={0, 0 };
   cin>>a>>b;
   x=a.size();y=b.size();

   for(i=1;i<=x;i++){
    for(j=1;j<=y;j++){

        if(a[i-1]==b[j-1]){ar[i][j]=1;}
    }
   }
   ll sum= 0;
   for(i=1;i<=x;i++){
    for(j=1;j<=y;j++){

       if(ar[i][j]==1){ ar[i][j]=ar[i][j]+ar[i-1][j-1];}sum=max(sum,ar[i][j]);
    }
   }

   cout<<x+y-2*sum<<en;

   }
}


