#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >>t;
    while (t--){
        string s,s1;
        cin >> s; cin >> s1;
        int n = s.size(), m = s1.size(), sum = 0;
        for (int i = 1; i <= min(n,m) ;i++)
            for (int j = 0;i + j <= n;j++)
                for (int k = 0;k + i <= m;k++)
                    if(s.substr(j, i) == s1.substr(k,i))
                        sum = max(i,sum);
        cout << s.size() + s1.size() - 2 * sum << endl;

    }
    



}