#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
mt19937_64 gen(time(0));
const long long N = 1e5 + 5;
const long long M = 1e5 + 10;
const long double eps = 1e-9;
const long long inf = 1e10;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a == d || b == c)
      cout << a + c << '\n';
    else
      cout << max(a + b, c + d) << '\n';
  }
}
