#include <bits/stdc++.h>
#define mod 1000000007
//#define mod 998244353
#define INF LLONG_MAX
#define NINF LLONG_MIN
#define ll long long int
#define pr(a) pair<a, a>
#define ps pair<int, string>
#define ff first
#define ss second
#define pub push_back
#define pob pop_back
#define f(i, a, b) for (int i = a; i <= b; i++)
#define r(i, a, b) for (int i = a; i >= b; i--)
#define ms(a, b) memset(a, b, sizeof(a))
#define line cout << '\n'
#define all(v) v.begin(), v.end()
#define rev(s) reverse(all(s))
using namespace std;

void Precompute()
{
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    Precompute();

    int tt = 1;
    cin >> tt;

    f(t, 1, tt)
    {
        string a, b;
        cin >> a >> b;

        int m = a.size(), n = b.size();

        int dp[m + 1][n + 1], mx = 0;

        ms(dp, 0);

        f(i, 1, m)
        {
            f(j, 1, n)
            {
                if(a[i - 1] == b[j - 1])
                {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                }
                else
                {
                    dp[i][j] = 0;
                }

                mx = max(mx, dp[i][j]);
            }
        }

        int ans = m + n - 2 * mx;

        cout << ans;

        line;
    }

    return 0;
}