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

int longest_substring(string s1,string s2){
    int arr[s1.length()][s2.length()], longest_substring_length=0;

    for(int i=0;i<s1.length(); i++){
        for(int j=0;j< s2.length();j++){
            if(s1[i]==s2[j] && (i>0&&j>0)){
                arr[i][j] = arr[i-1][j-1]+1;
            }else if(s1[i]==s2[j]){
                arr[i][j] = 1;
            }else{
                arr[i][j] = 0;
            }
        }
    }

    for(int i=0;i<s1.length();i++){
        for(int j=0;j<s2.length();j++){
            if(arr[i][j]> longest_substring_length)
                longest_substring_length=arr[i][j];
        }
    }
    int result = s1.length()+s2.length()-2*longest_substring_length;
    return result;
}

int main(){
    int t;
    string s1,s2;

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    cin>>t;

    while(t--){
        cin>>s1>>s2;
        cout<<longest_substring(s1,s2)<<"\n";    
    }
}