#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = min(a, d);
    int y = max(b, c);
    int xy = x + y;
    int p = max(a, d);
    int q = min(b, c);
    int pq = p + q;
    cout << max(xy, pq) << endl;
  }
}
