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

#define int long long
#define endl "\n"
#define deb(x) cout << #x << " = " << x << endl;

#define supafast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int MOD = 1e9 + 7;

void solution()
{
    string a, b;
    cin >> a >> b;

    // deb(a) deb(b)

    if (a == b)
    {
    	cout << 0 << endl;
    	return;
    }

    int size = 0, max_size = 0, x = 0, y = 0, c = 0;

    for (int i = 0; i < a.length(); i++)
    {
    	
    	for (int j = 0; j < b.length(); j++)
    	{
    		if (a[i] == b[j])
    		{
    			x = i;
    			y = j;
    			while(true)
    			{
    				if(x >= a.length() || y >= b.length())
    					break;

    				if (a[x] == b[y])
    				{
    					size++;
    				}
    				else
    				{
    					break;
    				}

    				x++;
    				y++;

    				c++;
    				if (c >= 100) break;
    			}
    		}
    		max_size = max(size, max_size);
    		size = 0;
    	}
    }

    int res = a.length() + b.length() - 2 * max_size;

    // deb(max_size)
    cout << res << endl;
}

int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    supafast

    int testCases = 1;
    cin >> testCases;
    while (testCases-- > 0)
    {
        solution();
    }
    return 0;
}