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

int LCSubStr(string str1, string str2)
{
    int LCSuff[str1.size() + 1][str2.size() + 1];
    int result = 0;
    for (int i = 0; i <= str1.size(); i++)
    {
        for (int j = 0; j <= str2.size(); j++)
        {
            if (i == 0 || j == 0)
                LCSuff[i][j] = 0;

            else if (str1[i - 1] == str2[j - 1]) {
                LCSuff[i][j] = LCSuff[i - 1][j - 1] + 1;
                result = max(result, LCSuff[i][j]);
            }
            else
                LCSuff[i][j] = 0;
        }
    }
    return result;
}

int main()
{
    int t;
    cin>>t;
    string a,b;
    while(t--)
    {
        cin>>a;
        cin>>b;
        int maxm;
        maxm = LCSubStr(a,b);
        cout<<(a.size() + b.size() - (2 * maxm))<<endl;
    }
    return 0;
}
