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

using ll = long long;
using str = string;

#define fi(i,a,b) for(int i=a; i<=b; i++)
#define fid(i,a,b) for(int i=a; i>=b; i--)
#define fj(j,a,b) for(int j=a; i<=b; i++)
#define fl(i,a,b) for(ll i=a; i<=b; i++)
#define fld(i,a,b) for(ll i=a; i>=b; i--)
#define io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fs first;
#define sc second;

const int maxi = 1e9+7;
const int tbi = 1e5+5;


int main()
{
    int t;
    cin>>t;

    while(t--)
    {
        str a, b;
        int tg, ans=0, i1;
        cin>>a;
        cin>>b;

        int n1=a.size()-1, n2=b.size()-1;

        for (int i=0; i<=n1; i++)
        {
            tg=0;
            i1=i;
            for (int j=0; j<=n2; j++)
            {
                if (a[i1] == b[j] and i1<=n1)
                {
                    //cout<<i1<<" "<<j<<endl;
                    tg++;
                    i1++;
                }
                else
                {
                  if (a[i]==b[j]) j--;
                   tg=0;
                   i1=i;
                }
            ans = max(ans, tg);
            }
        }
        for (int i=0; i<=n2; i++)
        {
            tg=0;
            i1=i;
            for (int j=0; j<=n1; j++)
            {
                if (a[j] == b[i1] and i1<=n2)
                {
                    //cout<<i1<<" "<<j<<endl;
                    tg++;
                    i1++;
                }
                else
                {
                   if (b[i]==a[j]) j--;
                   tg=0;
                   i1=i;
                }
            ans = max(ans, tg);
            }
        }

        cout<<n1 + n2 - 2*ans + 2<<endl;
    }


}

