#include <bits/stdtr1c++.h>
using namespace std;

typedef long double ld;
typedef complex<ld> pt;

const ld EPS = 1e-5;

pt a, b;
ld ab;

inline ld p(const pt& c, const pt& d) {
  return ab+abs(d-c)+min(abs(b-d)+abs(c-a),abs(a-d)+abs(c-b));
}

inline ld f(const ld& x) {
  pt d(x,0);
  ld lo = 0, hi = 10000;
  while (hi-lo > EPS) {
    ld m1 = lo+(hi-lo)/3, m2 = lo+(hi-lo)*2/3;
    pt c1(0,m1), c2(0,m2);
    if (p(c1,d) < p(c2,d))
      hi = m2;
    else
      lo = m1;
  }
  return p(pt(0,lo),d);
}

int main() {
  ios::sync_with_stdio(0);
  int t; cin >> t;
  while (t--) {
    ld ax, ay, bx, by;
    cin >> ax >> ay >> bx >> by;
    a = pt(ax,ay);
    b = pt(bx,by);
    ab = abs(a-b);
    ld lo = 0, hi = 10000;
    while (hi-lo > EPS) {
      ld m1 = lo+(hi-lo)/3, m2 = lo+(hi-lo)*2/3;
      if (f(m1) < f(m2))
        hi = m2;
      else
        lo = m1;
    }
    cout << fixed << setprecision(3) << f(lo) << "\n";
  }
  return 0;
}