#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll power(ll a, ll b){
    ll res=1;
    while(b){
        if(b&1) res=(res*a);
        a=(a*a);
        b>>=1;
    }
    return res;
}

int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		ll i,j,p,k;
		string a,b;
		cin>>a>>b;
		ll n=a.size();
		ll m=b.size();
		ll cnt=0;
		ll ans=0;
		for(i=n;i>0;i--)
		{
			for(j=0;j<=m-i;j++)
			{
				for(k=0;k<=n-i;k++)
				{
					for(p=j;p<j+i;p++)
					{
					if(a[p-j+k]==b[p])
					cnt++;
					}
					if(cnt==i)
					{
					ans=i;
					}
					cnt=0;
				}
			}
			if(ans>0)
			break;
		}
		cout<<n+m-2*ans<<endl;
	}
}
