#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, m, r, c;
  for (scanf("%d", &t); t--;)
    scanf("%d%d%d%d", &n, &m, &r, &c),
        printf("%d\n",
               max(max(abs(n - r) + abs(m - c), abs(r - 1) + abs(c - 1)),
                   max(abs(n - r) + abs(c - 1), abs(r - 1) + abs(m - c))));
  return 0;
}
