#include<iostream>
#include<queue>
#include<vector>
#include<math.h>
#define ll long long int
using namespace std;
/*----–--gcd and hcf *------------*/
ll gcd(ll a,ll b){
	if(b==0)
	return a;
	return gcd(b,a%b);
}
ll ceilV(ll x,ll y){
   return (x%y==0?x/y:(x/y+1));
}

ll sieveOfPrime(ll x){
  ll max=1000;
  //cin>>max;	//for taking sieve size
 int isPrime[max+1];
	isPrime[0]=isPrime[1]=0;
	
for(ll i=2;i<=max;i++){
	isPrime[i]=1;
		}
			
	for(ll i=2;i*i<=max;i++){
		if(isPrime[i]){
		for(ll j=i*i;j<=max;j+=i){
			isPrime[j]=0;
		}
		
		}
		
	}
//	for(ll i=2;i<=max;i++){
//			cout<<i<<" "<<isPrime[i]<<endl;
//	}
	return isPrime[x];
}

void primeFactorizationLogn(ll n,ll x){
	ll prime[n+1];
	for(ll i=0;i<=n;i++){
		prime[i]=i;
	}
	for(ll i=2;i*i<=n;i++){
		if(prime[i]==i){
			for(ll j=i*i;j<=n;j+=i){
			prime[j]=i;	
			}
		}
		
	}
	while(x!=1){
	cout<<prime[x]<<" ";	
	x=x/prime[x];	
	}
}

ll lcSubstring(string a,string b){
	   ll max=0;
	   ll dp[a.length()+1][b.length()+1];
	   for(ll i=0;i<=a.length();i++){
	   	for(ll j=0;j<=b.length();j++){
	   		if(i==0||j==0){
	   			dp[i][j]=0;
	   		}else if(a[i-1]==b[j-1]){
	   			dp[i][j]=dp[i-1][j-1]+1;
	   			
	   		}else{
	   			dp[i][j]=0;
	   			
	   		}
	   		if(dp[i][j]>max){
	   			max=dp[i][j];
	   				}	
	   	}
	   	
	   }
	return max;
}

void fun(){
     string a,b;	
     cin>>a>>b;
     ll max=lcSubstring(a,b);
     //cout<<max<<endl;
 cout<<a.length()+b.length()-2*max<<endl;

}
int main()
{
	ll t;
	cin>>t;
	while(t--){
	fun();	
	}
	return 0;
}