#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
     ll t;
	 cin >> t;
	 while(t--){
         string a , b;
		 cin >> a >> b;
		 ll m = a.length() , n = b.length();
		 ll lcs[m + 1][n + 1];
		 ll ans = 0;
		 for(ll i = 0; i <= m; i++){
			 for(ll j = 0; j <= n; j++){
				 if(i == 0 || j == 0)  lcs[i][j] = 0;
				 else if(a[i - 1] == b[j - 1]){
						 lcs[i][j] = 1 + lcs[i - 1][j - 1];
						 ans = max(ans , lcs[i][j]);
				 }
					 else lcs[i][j] = 0;
			 }
		 }
		 cout << m + n - 2 * ans << endl;
	 }
	return 0;
}