#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  int test;
  cin >> test;
  while (test--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a == d && b == c)
      cout << a + b << "\n";
    else {
      int ar[3];
      ar[0] = a + 1 + c;
      ar[1] = a + b;
      ar[2] = c + d;
      sort(ar, ar + 3);
      cout << ar[1] << "\n";
    }
  }
  return 0;
}
