#include <bits/stdc++.h>
using namespace std;
inline long long getint() {
  long long _x = 0, _tmp = 1;
  char _tc = getchar();
  while ((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
  if (_tc == '-') _tc = getchar(), _tmp = -1;
  while (_tc >= '0' && _tc <= '9') _x *= 10, _x += (_tc - '0'), _tc = getchar();
  return _x * _tmp;
}
inline long long add(long long _x, long long _y,
                     long long _mod = 1000000007ll) {
  long long _ = _x + _y;
  if (_ >= _mod) _ -= _mod;
  return _;
}
inline long long sub(long long _x, long long _y,
                     long long _mod = 1000000007ll) {
  long long _ = _x - _y;
  if (_ < 0) _ += _mod;
  return _;
}
inline long long mul(long long _x, long long _y,
                     long long _mod = 1000000007ll) {
  long long _ = _x * _y;
  if (_ >= _mod) _ %= _mod;
  return _;
}
long long mypow(long long _a, long long _x, long long _mod) {
  if (_x == 0) return 1ll;
  long long _tmp = mypow(_a, _x / 2, _mod);
  _tmp = mul(_tmp, _tmp, _mod);
  if (_x & 1) _tmp = mul(_tmp, _a, _mod);
  return _tmp;
}
long long mymul(long long _a, long long _x, long long _mod) {
  if (_x == 0) return 0ll;
  long long _tmp = mymul(_a, _x / 2, _mod);
  _tmp = add(_tmp, _tmp, _mod);
  if (_x & 1) _tmp = add(_tmp, _a, _mod);
  return _tmp;
}
inline bool equal(double _x, double _y) {
  return _x > _y - 1e-9 && _x < _y + 1e-9;
}
int __ = 1, _cs;
void build() {}
long long x[100], y[100];
void init() {
  for (int i = 0; i < 4; i++) {
    x[i] = getint();
    y[i] = getint();
  }
}
long long ans, ax[100], ay[100], tx[100], ty[100], d[100];
void update(long long tans, const vector<int>& per) {
  ans = tans;
  for (int i = 0; i < 4; i++) {
    ax[i] = tx[per[i]];
    ay[i] = ty[per[i]];
  }
}
long long kx[100], ky[100];
void update_kans(long long tans) {
  if (ans == -1 || tans < ans) {
    ans = tans;
    for (int i = 0; i < 4; i++) {
      ax[i] = kx[i];
      ay[i] = ky[i];
    }
  }
}
void check_ans() {
  vector<int> per;
  for (int i = 0; i < 4; i++) per.push_back(i);
  do {
    long long tans = 0;
    bool flag = true;
    for (int i = 0; i < 4; i++) {
      if (d[i] == 0) {
        if (y[i] != ty[per[i]]) {
          flag = false;
          break;
        }
        tans = max(tans, abs(x[i] - tx[per[i]]));
      } else {
        if (x[i] != tx[per[i]]) {
          flag = false;
          break;
        }
        tans = max(tans, abs(y[i] - ty[per[i]]));
      }
    }
    if (flag && (ans == -1 || tans < ans)) update(tans, per);
  } while (next_permutation((per).begin(), (per).end()));
}
void cal() {
  vector<long long> xx, yy;
  for (int i = 0; i < 4; i++)
    if (d[i] == 0)
      yy.push_back(y[i]);
    else
      xx.push_back(x[i]);
  sort((xx).begin(), (xx).end());
  xx.resize(unique((xx).begin(), (xx).end()) - xx.begin());
  sort((yy).begin(), (yy).end());
  yy.resize(unique((yy).begin(), (yy).end()) - yy.begin());
  if ((int)xx.size() > 2 || (int)yy.size() > 2) return;
  if ((int)xx.size() == 2 && (int)yy.size() == 2) {
    if (xx[0] == xx[1]) return;
    if (xx[1] - xx[0] != yy[1] - yy[0]) return;
    tx[0] = xx[0];
    ty[0] = yy[0];
    tx[1] = xx[0];
    ty[1] = yy[1];
    tx[2] = xx[1];
    ty[2] = yy[0];
    tx[3] = xx[1];
    ty[3] = yy[1];
    check_ans();
  } else if ((int)xx.size() == 2 && (int)yy.size() == 1) {
    if (xx[0] == xx[1]) return;
    long long dd = xx[1] - xx[0];
    tx[0] = xx[0];
    ty[0] = yy[0];
    tx[1] = xx[0];
    ty[1] = yy[0] + dd;
    tx[2] = xx[1];
    ty[2] = yy[0];
    tx[3] = xx[1];
    ty[3] = yy[0] + dd;
    check_ans();
    tx[1] = xx[0];
    ty[1] = yy[0] - dd;
    tx[3] = xx[1];
    ty[3] = yy[0] - dd;
    check_ans();
  } else if ((int)yy.size() == 2 && (int)xx.size() == 1) {
    if (yy[0] == yy[1]) return;
    long long dd = yy[1] - yy[0];
    tx[0] = xx[0];
    ty[0] = yy[0];
    tx[1] = xx[0];
    ty[1] = yy[1];
    tx[2] = xx[0] + dd;
    ty[2] = yy[0];
    tx[3] = xx[0] + dd;
    ty[3] = yy[1];
    check_ans();
    tx[2] = xx[0] - dd;
    ty[2] = yy[0];
    tx[3] = xx[0] - dd;
    ty[3] = yy[1];
    check_ans();
  } else if ((int)xx.size() == 2) {
    long long dd = xx[1] - xx[0];
    vector<int> p[2];
    for (int i = 0; i < 4; i++) {
      if (x[i] == xx[0])
        p[0].push_back(i);
      else
        p[1].push_back(i);
    }
    if ((int)p[0].size() != 2 || (int)p[1].size() != 2) return;
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        long long bl = 0, br = 1000000000ll, bmid;
        while (bl <= br) {
          bmid = (bl + br) >> 1;
          long long ty1 = max(y[p[0][0]] - bmid, y[p[1][0]] - bmid);
          long long ty2 = min(y[p[0][0]] + bmid, y[p[1][0]] + bmid);
          long long ty3 = max(y[p[0][1]] - bmid, y[p[1][1]] - bmid);
          long long ty4 = min(y[p[0][1]] + bmid, y[p[1][1]] + bmid);
          bool okay = false;
          if (ty1 <= ty2 && ty3 <= ty4) {
            if (max(ty1 + dd, ty3) <= min(ty2 + dd, ty4)) {
              okay = true;
              kx[p[0][0]] = xx[0];
              ky[p[0][0]] = max(ty1 + dd, ty3) - dd;
              kx[p[0][1]] = xx[0];
              ky[p[0][1]] = max(ty1 + dd, ty3);
              kx[p[1][0]] = xx[1];
              ky[p[1][0]] = max(ty1 + dd, ty3) - dd;
              kx[p[1][1]] = xx[1];
              ky[p[1][1]] = max(ty1 + dd, ty3);
              update_kans(bmid);
            }
            if (max(ty1 - dd, ty3) <= min(ty2 - dd, ty4)) {
              okay = true;
              kx[p[0][0]] = xx[0];
              ky[p[0][0]] = max(ty1 - dd, ty3) + dd;
              kx[p[0][1]] = xx[0];
              ky[p[0][1]] = max(ty1 - dd, ty3);
              kx[p[1][0]] = xx[1];
              ky[p[1][0]] = max(ty1 - dd, ty3) + dd;
              kx[p[1][1]] = xx[1];
              ky[p[1][1]] = max(ty1 - dd, ty3);
              update_kans(bmid);
            }
          }
          if (okay)
            br = bmid - 1;
          else
            bl = bmid + 1;
        }
        swap(p[1][0], p[1][1]);
      }
      swap(p[0][0], p[0][1]);
    }
  } else if ((int)yy.size() == 2) {
    long long dd = yy[1] - yy[0];
    vector<int> p[2];
    for (int i = 0; i < 4; i++) {
      if (y[i] == yy[0])
        p[0].push_back(i);
      else
        p[1].push_back(i);
    }
    if ((int)p[0].size() != 2 || (int)p[1].size() != 2) return;
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        long long bl = 0, br = 1000000000ll, bmid;
        while (bl <= br) {
          bmid = (bl + br) >> 1;
          long long ty1 = max(x[p[0][0]] - bmid, x[p[1][0]] - bmid);
          long long ty2 = min(x[p[0][0]] + bmid, x[p[1][0]] + bmid);
          long long ty3 = max(x[p[0][1]] - bmid, x[p[1][1]] - bmid);
          long long ty4 = min(x[p[0][1]] + bmid, x[p[1][1]] + bmid);
          bool okay = false;
          if (ty1 <= ty2 && ty3 <= ty4) {
            if (max(ty1 + dd, ty3) <= min(ty2 + dd, ty4)) {
              okay = true;
              kx[p[0][0]] = max(ty1 + dd, ty3) - dd;
              ky[p[0][0]] = yy[0];
              kx[p[0][1]] = max(ty1 + dd, ty3);
              ky[p[0][1]] = yy[0];
              kx[p[1][0]] = max(ty1 + dd, ty3) - dd;
              ky[p[1][0]] = yy[1];
              kx[p[1][1]] = max(ty1 + dd, ty3);
              ky[p[1][1]] = yy[1];
              update_kans(bmid);
            }
            if (max(ty1 - dd, ty3) <= min(ty2 - dd, ty4)) {
              okay = true;
              kx[p[0][0]] = max(ty1 - dd, ty3) + dd;
              ky[p[0][0]] = yy[0];
              kx[p[0][1]] = max(ty1 - dd, ty3);
              ky[p[0][1]] = yy[0];
              kx[p[1][0]] = max(ty1 - dd, ty3) + dd;
              ky[p[1][0]] = yy[1];
              kx[p[1][1]] = max(ty1 - dd, ty3);
              ky[p[1][1]] = yy[1];
              update_kans(bmid);
            }
          }
          if (okay)
            br = bmid - 1;
          else
            bl = bmid + 1;
        }
        swap(p[1][0], p[1][1]);
      }
      swap(p[0][0], p[0][1]);
    }
  }
}
void solve() {
  ans = -1;
  for (int i1 = 0; i1 < 2; i1++)
    for (int i2 = 0; i2 < 2; i2++)
      for (int i3 = 0; i3 < 2; i3++)
        for (int i4 = 0; i4 < 2; i4++) {
          d[0] = i1;
          d[1] = i2;
          d[2] = i3;
          d[3] = i4;
          cal();
        }
  printf("%lld\n", ans);
  if (ans != -1) {
    for (int i = 0; i < 4; i++) printf("%lld %lld\n", ax[i], ay[i]);
  }
}
int main() {
  build();
  __ = getint();
  while (__--) {
    init();
    solve();
  }
}
