#include<bits/stdc++.h>

using namespace std;
int ans;

int main(){

    //freopen("input.txt", "r", stdin);
    int tc;
    cin>>tc;

    while(tc--){
        string a, b;
        cin>>a>>b;
        ans = 0;

        for(int i=0;i<a.length();i++){
            for(int j=0;j<b.length();j++){
                if(a[i]==b[j]){

                    int x = i;
                    int y = j;

                    while(1){
                        if(x >= a.length()) break;
                        if(y >= b.length()) break;
                        if(a[x] != b[y]) break;
                        x++; y++;
                    }

                    ans = max(x-i,ans);
                }
            }
        }

        cout<<(a.length()-ans)+(b.length()-ans)<<endl;

    }

    return 0;
}
/**
cdd
dcddbd
*/
