//Sudhanshukmr7724
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define pi 3.14159265358979323846
const int mod=1e9+7;
const int nax=1e5+5;

void solve(){
	string a,b;
	cin>>a>>b;
	int n=a.length(),m=b.length();
	int longest=0;
	for(int i=0;i<n;i++){
		int tmp=0,j=0;
		while(i+tmp<n&&j<m){
			if(a[i+tmp]==b[j+tmp]){
				tmp++;
			}
			else{
				longest=max(longest,tmp);
				tmp=0;
				j++;
			}
			longest=max(longest,tmp);	
		}	
		longest=max(longest,tmp);		
	}
	int ans=(n+m-2*longest);
	cout<<ans<<"\n";	
}

int32_t main(){
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);cout.tie(NULL);
		
	int t=1;
	cin>>t;
	while(t--){
		solve();
	}
	
	
	return 0;
}