#include <bits/stdc++.h>
using namespace std;
long long distance(long long x1, long long y1, long long x2, long long y2) {
  return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}
int32_t main() {
  long long t = 1;
  cin >> t;
  while (t--) {
    long long x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    long long ans = -1;
    if (y1 == y2 || x1 == x2) {
      ans = distance(x1, y1, x2, y2);
    } else {
      long long arb_x, arb_y;
      if (y1 < y2) {
        arb_x = x1;
        arb_y = y2;
        ans = distance(arb_x, arb_y, x1, y1);
        ans += distance(arb_x, arb_y, x2, y2);
      } else {
        arb_x = x2;
        arb_y = y1;
        ans = distance(arb_x, arb_y, x2, y2);
        ans += distance(arb_x, arb_y, x1, y1);
      }
      ans += 2;
    }
    cout << ans << "\n";
  }
  return 0;
}
