#include<bits/stdc++.h>
using namespace  std;
 
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define ll           long long  
#define int          long long
#define vi           std::vector<int>
#define setbits(x)   __builtin_popcountll(x)
#define pb           push_back
#define fn           for(int i=0;i<n;i++)
#define rep(i,a,b)   for(int i=a;i<b;i++)
#define all(x)       x.begin(), x.end()
#define  ret(x) {cout << #x << endl; return;}
#define PI           3.14159265358979323846
#define deb(x) cout<<#x<<" = "<<x<<endl;
#define pii          pair<ll,ll>
#define fr           first
#define sc           second
 
const int mod = 1e9+7;
void getio();
ll ceill(ll a, ll b) { return (a + b - 1) / b; }

int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

bool isSubstring(string s1, string s2)
{
    int M = s1.length();
    int N = s2.length();
    for (int i = 0; i <= N - M; i++) {
        int j;
        for (j = 0; j < M; j++)
            if (s2[i + j] != s1[j])
                break;
 
        if (j == M)
            return 1;
    }
 
    return 0;
}

void solve()
{
    string a, b;
    cin >> a >> b;
    int n = a.size();
    int m = b.size();
    int ans = m+n;

for (int i = 0; i < n; i++) {

        for (int j = i; j < n; j++) {
                string tem = "";
            for (int k = i; k <= j; k++) {
                // cout << a[k];
                tem += a[k];
            }
            // cout << endl;
            if(isSubstring(tem, b)) {
                int siz = tem.size();
                // cout << siz << endl;
                ans = min(n-siz+m-siz, ans);
            }
        }
    }
    // cout << endl;
    cout << ans << endl;
}


int32_t main()
{   
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    getio();
    int t; cin >> t; while(t--)
    solve();

}
 
void getio()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}