#include <bits/stdc++.h>

using namespace std;

#ifdef EBBY
#include <debug.hpp>
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define debug(...) ;
#endif

#define fastio ios::sync_with_stdio(false), cin.tie(nullptr)
#define all(A) begin(A), end(A)

typedef long long ll;

int main() {
  fastio;
  int t;
  cin >> t;
  while (t--) {
    string a, b;
    cin >> a >> b;
    int n = a.size(), m = b.size();
    int ans = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i; j < n; j++) {
        int s = j - i + 1;
        if (s > m) continue;
        if (b.find(a.substr(i, s)) != b.npos)
          ans = max(ans, s);
      }
    }
    debug(ans);
    ans = n + m - 2 * ans;
    cout << ans << '\n';
  }
  return 0;
}
