#include <bits/stdc++.h>
using namespace std;
int lcstr (string s1, string s2, int n, int m)
    {
        // your code here
        int dp[n+1][m+1];int ans=0;
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=m;j++)
            {
                if(i==0 or j==0)dp[i][j]=0;
                else
                {
                    if(s1[i-1]==s2[j-1]){dp[i][j]=1+dp[i-1][j-1];ans=max(ans,dp[i][j]);}
                    else dp[i][j]=0;
                }
            }
        }
        return ans;
    }
int main() 
{
    int t;cin>>t;
    while(t--)
    {
        string a,b;cin>>a>>b;
        int val=lcstr(a,b,a.length(),b.length());
        int ans=a.length()-val+b.length()-val;
        cout<<ans<<endl;
    }
    return 0;
}