#include <bits/stdc++.h>
using namespace std;
int main(){
	int t;
    cin >> t;
	for(int test=0;test<t;test++){
        string s1,s2;
        cin>>s1;
        cin>>s2;

        int dp[25][25];
        int ans=0;
        for(int i=0;i<=s1.length();i++){
            for(int j=0;j<=s2.length();j++){
                if(i==0 || j==0){
                    dp[i][j]=0;
                }
                else if(s1[i-1]==s2[j-1]){
                    dp[i][j]=dp[i-1][j-1]+1;
                    ans=max(ans,dp[i][j]);
                }else{
                    dp[i][j]=0;
                }
            }
        }
        cout<<s1.length()+s2.length()-2*ans<<"\n";
	}
	return 0;
}
