#include <bits/stdc++.h>
using namespace std;
namespace io {
const int SI = 1 << 21 | 1;
char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100];
int f, t;
inline void flush() { fwrite(OB, 1, OS - OB, stdout), OS = OB; }
inline void pc(char x) {
  *OS++ = x;
  if (OS == OT) flush();
}
template <class I>
inline void rd(I &x) {
  for (f = 1, c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                              IS == IT ? EOF : *IS++)
                            : *IS++);
       c < '0' || c > '9';
       c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                       IS == IT ? EOF : *IS++)
                     : *IS++))
    if (c == '-') f = -1;
  for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15),
      c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                      IS == IT ? EOF : *IS++)
                    : *IS++))
    ;
  x *= f;
}
template <class I>
inline void rda(I *a, int &n) {
  for (int i = 1; i <= n; i++) rd(a[i]);
}
inline void rds(char *s, int &x) {
  for (c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                       IS == IT ? EOF : *IS++)
                     : *IS++);
       c < 33 || c > 126;
       c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                       IS == IT ? EOF : *IS++)
                     : *IS++))
    ;
  for (x = 0; c >= 33 && c <= 126;
       s[++x] = c, c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin),
                                   IS == IT ? EOF : *IS++)
                                 : *IS++))
    ;
  s[x + 1] = '\0';
}
template <class I>
inline void print(I x, char k = '\n') {
  if (!x) pc('0');
  if (x < 0) pc('-'), x = -x;
  while (x) ch[++t] = x % 10 + '0', x /= 10;
  while (t) pc(ch[t--]);
  pc(k);
}
inline void prints(string s) {
  int x = s.length();
  while (t < x) pc(s[t++]);
  pc('\n'), t = 0;
}
struct Flush {
  ~Flush() { flush(); }
} flusher;
}  // namespace io
using io::print;
using io::prints;
using io::rd;
using io::rda;
using io::rds;
const int inf = 1e9;
int p[4], x[4], y[4], ax[4], ay[4], bx[4], by[4], cx, cy, ans;
int lx[4], xy[4][5], ly[4], yx[4][5];
inline void check() {
  int d01 = abs(bx[0] == bx[1] ? by[0] - by[1] : bx[0] - bx[1]);
  int d02 = abs(bx[0] == bx[2] ? by[0] - by[2] : bx[0] - bx[2]);
  int d31 = abs(bx[3] == bx[1] ? by[3] - by[1] : bx[3] - bx[1]);
  int d32 = abs(bx[3] == bx[2] ? by[3] - by[2] : bx[3] - bx[2]);
  if (d01 != d02 || d02 != d31 || d31 != d32) return;
  do {
    int mx = 0;
    for (int i = 0; i < 4; i++) {
      if (x[i] != bx[p[i]] && y[i] != by[p[i]]) {
        mx = inf;
        break;
      }
      if (x[i] == bx[p[i]])
        mx = max(mx, abs(y[i] - by[p[i]]));
      else
        mx = max(mx, abs(x[i] - bx[p[i]]));
    }
    if (mx < ans) {
      ans = mx;
      for (int i = 0; i < 4; i++) ax[i] = bx[p[i]], ay[i] = by[p[i]];
    }
  } while (next_permutation(p, p + 4));
}
inline void pd() {
  if (cx == 2 && cy == 2) {
    bx[0] = lx[0], by[0] = ly[0];
    bx[1] = lx[0], by[1] = ly[1];
    bx[2] = lx[1], by[2] = ly[0];
    bx[3] = lx[1], by[3] = ly[1];
    check();
  } else if (cy == 1) {
    bx[0] = lx[0], by[0] = ly[0];
    bx[1] = lx[1], by[1] = ly[0];
    bx[2] = lx[0], by[2] = ly[0] + (lx[0] - lx[1]);
    bx[3] = lx[1], by[3] = ly[0] + (lx[0] - lx[1]);
    check();
    bx[2] = lx[0], by[2] = ly[0] - (lx[0] - lx[1]);
    bx[3] = lx[1], by[3] = ly[0] - (lx[0] - lx[1]);
    check();
  } else if (cx == 1) {
    bx[0] = lx[0], by[0] = ly[0];
    bx[1] = lx[0], by[1] = ly[1];
    bx[2] = lx[0] + (ly[0] - ly[1]), by[2] = ly[0];
    bx[3] = lx[0] + (ly[0] - ly[1]), by[3] = ly[1];
    check();
    bx[2] = lx[0] - (ly[0] - ly[1]), by[2] = ly[0];
    bx[3] = lx[0] - (ly[0] - ly[1]), by[3] = ly[1];
    check();
  } else if (cy == 0) {
    int d = abs(lx[0] - lx[1]);
    sort(xy[0] + 1, xy[0] + 3);
    sort(xy[1] + 1, xy[1] + 3);
    int a[4] = {xy[0][1], xy[0][2] - d, xy[1][1], xy[1][2] - d};
    sort(a, a + 4);
    int z = (a[0] + a[3]) >> 1;
    bx[0] = lx[0], by[0] = z;
    bx[1] = lx[0], by[1] = z + d;
    bx[2] = lx[1], by[2] = z;
    bx[3] = lx[1], by[3] = z + d;
    check();
  } else {
    int d = abs(ly[0] - ly[1]);
    sort(yx[0] + 1, yx[0] + 3);
    sort(yx[1] + 1, yx[1] + 3);
    int a[4] = {yx[0][1], yx[0][2] - d, yx[1][1], yx[1][2] - d};
    sort(a, a + 4);
    int z = (a[0] + a[3]) >> 1;
    bx[0] = z, by[0] = ly[0];
    bx[1] = z + d, by[1] = ly[0];
    bx[2] = z, by[2] = ly[1];
    bx[3] = z + d, by[3] = ly[1];
    check();
  }
}
inline void solve() {
  ans = inf;
  for (int i = 0; i < 4; i++) rd(x[i]), rd(y[i]);
  for (int k = 0; k < 16; k++) {
    cx = cy = 0;
    for (int i = 0; i < 4; i++)
      if (k >> i & 1) {
        int o = -1;
        for (int j = 0; j < cx; j++)
          if (lx[j] == x[i]) o = j;
        if (~o)
          xy[o][++*xy[o]] = y[i];
        else
          xy[cx][*xy[cx] = 1] = y[i], lx[cx++] = x[i];
      } else {
        int o = -1;
        for (int j = 0; j < cy; j++)
          if (ly[j] == y[i]) o = j;
        if (~o)
          yx[o][++*yx[o]] = x[i];
        else
          yx[cy][*yx[cy] = 1] = x[i], ly[cy++] = y[i];
      }
    if (max(cx, cy) != 2 || (!cy && *xy[0] != 2) || (!cx && *yx[0] != 2))
      continue;
    pd();
  }
  if (ans == inf) return print(-1), void();
  print(ans);
  for (int i = 0; i < 4; i++) print(ax[i], ' '), print(ay[i]);
}
int main() {
  for (int i = 0; i < 4; i++) p[i] = i;
  int T;
  rd(T);
  while (T--) solve();
  return 0;
}
