#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int a, b, c, d, c1, c2, c3;
    cin >> a >> b >> c >> d;
    c1 = a + b;
    c2 = c + d;
    c3 = max(c1, c2);
    cout << min(c3, a + c) << endl;
  }
  return 0;
}
