#include<bits/stdc++.h>
#define int long long
#define float double
#define itn int
#define f(j,n) for(int i=j;i<n;i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl '\n'
#define Endl '\n'
#define ednl '\n'
#define Ednl '\n'
#define pb push_back
#define mp make_pair
#define mod 1000000000000000000
#define mset(arr, i) memset(arr, i, sizeof(arr))
using namespace std;
 
typedef vector<pair<int, int>> vpi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef map<int,int> mii;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vector<int>, greater<int>> pqim;
 
long long binpow(long long a, long long b) { a %= mod; long long res = 1; while (b > 0){if (b & 1)res = res * a % mod;a = a * a % mod;b >>= 1;}return res;}

int LCSubStr(string X, string  Y, int m, int n)
{ 
    int LCSuff[m + 1][n + 1];
    int result = 0; 
    for (int i = 0; i <= m; i++)
    {
        for (int j = 0; j <= n; j++)
        {
            if (i == 0 || j == 0)
                LCSuff[i][j] = 0;
 
            else if (X[i - 1] == Y[j - 1]) {
                LCSuff[i][j] = LCSuff[i - 1][j - 1] + 1;
                result = max(result, LCSuff[i][j]);
            }
            else
                LCSuff[i][j] = 0;
        }
    }
    return result;
}

int32_t main()
{
    int t1;
    fastio;
    cin>>t1; 
    //t1=1;
    while(t1--)
    {
        string a, b;
        cin>>a>>b;
        int n1=a.length(), n2 = b.length();
        int ans = LCSubStr(a, b, n1, n2);
        cout<<n1+n2-2*ans<<endl;
    }
    
}
