#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
#define N 20005
typedef long long ll;
#define inf 9999999999999
int t;
int ans = 0;

int main() {
	cin >> t;
	while (t--) {
        ans = 0;
        bool strt = false;
        string a, b;
        cin >> a >> b;
        string str;
        int m1 = a.size();
        int m2 = b.size();
        for (int i = 0; i <m1; i++)
        {
            for (int j = i; j < m1; j++)
            {
                str += a[j];
                int tt = str.size();
                for (int k = 0; k < b.size(); k++)
                {
                    
                    if (b.substr(k, tt) == str)
                    {
                        ans = max(ans, tt);
                    }
                }
            }
            str = "";
        }
        cout << m1 + m2 - (2 * ans) << endl;
	}
}