#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <iomanip>
#include <random>
//#include <fstream>
/*#include <cstdio>
#include <ctime>*/

using namespace std;

void solve()
{
	string a, b;
	cin >> a >> b;
	unordered_set<string> b_set;
	string temp;
	if (a.length() > b.length())
	{
		temp = b;
		b = a;
		a = temp;

	}//a is always the shorter one 
	for (int last = b.length(); last >= 0; last--)
		for (int i = 0; i < last; i++)
			b_set.insert(b.substr(i, last - i));
	int maX = 0;
	for (int last = a.length(); last >= 0; last--)
		for (int i = 0; i < last; i++)
		{
			temp = a.substr(i, last - i);
			if (b_set.find(temp) != b_set.end())
			{
				maX = max(maX, (int)temp.length());
			}
		}
	cout <<int(a.length() + b.length()) - 2 * maX << endl;
}
int main() {
	int t = 1;
	cin >> t;
	while (t--)
		solve();
	return 0;
}