#include <bits/stdc++.h> // doubleEndedStrings.cpp Angel Patino 4/29/2021 :)
using namespace std;

int lcs(string a, string b);
int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); // For speed :D
    int t, min_op; // t = # of test cases
    string a, b;
    cin >> t;
    while(t--){
        cin >> a >> b;
        min_op = a.size() + b.size() - 2*lcs(a, b);
        cout << min_op << '\n';
    }
    return 0;
}

int lcs(string a, string b){
    int m = a.size(), n = b.size(), maxlen = 0;
    int memo[m+1][n+1];
    memset( memo, 0, sizeof(memo) );
    for (int i = 1; i <= m; ++i)
        for (int j = 1; j <= n; ++j)
            if (a[i-1] == b[j-1]){
                memo[i][j] = memo[i-1][j-1] + 1;
                if(memo[i][j] > maxlen)
                    maxlen = memo[i][j];
            }
    return maxlen;
}