#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
inline void write(int x) {
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
const int inf = 1e9;
struct Point {
  int x, y;
  Point(int xx = 0, int yy = 0) { x = xx, y = yy; }
  inline void init() { read(x), read(y); }
  inline void print() { printf("%d %d\n", x, y); }
} a[4];
inline int dis(Point A, Point B) { return abs(A.x - B.x) + abs(A.y - B.y); }
Point ans[4], p[4];
int Ans;
bool ff;
inline void upd() {
  static int q[4], i, mx;
  q[0] = 0, q[1] = 1, q[2] = 2, q[3] = 3;
  if (ff)
    for (i = 0; i < 4; ++i) swap(a[i].x, a[i].y), swap(p[i].x, p[i].y);
  do {
    for (mx = i = 0; i < 4; ++i)
      if (p[q[i]].x != a[i].x && p[q[i]].y != a[i].y) mx = inf;
    for (i = 0; i < 4; ++i) mx = max(mx, dis(a[i], p[q[i]]));
    if (mx < Ans)
      for (Ans = mx, i = 0; i < 4; ++i) ans[i] = p[q[i]];
  } while (next_permutation(q, q + 4));
  if (ff)
    for (i = 0; i < 4; ++i) swap(a[i].x, a[i].y), swap(p[i].x, p[i].y);
}
int cntx, cnty, vx[5], vy[5];
inline void solve(int s) {
  int i, j;
  cntx = cnty = 0;
  for (i = 0; i < 4; ++i)
    if (s >> i & 1)
      vx[cntx++] = a[i].x;
    else
      vy[cnty++] = a[i].y;
  sort(vx, vx + cntx), cntx = unique(vx, vx + cntx) - vx;
  sort(vy, vy + cnty), cnty = unique(vy, vy + cnty) - vy;
  if (cntx != 2 || cnty > 2) return;
  if (!cnty) {
    int L = abs(vx[0] - vx[1]), ay = -inf, by = -inf, cy = -inf, dy = -inf;
    for (i = 0; i < 4; ++i) {
      if (a[i].x == vx[0]) {
        if (ay == -inf)
          ay = a[i].y;
        else
          by = a[i].y;
      } else {
        if (cy == -inf)
          cy = a[i].y;
        else
          dy = a[i].y;
      }
    }
    if (by == -inf || dy == -inf) return;
    if (ay > by) swap(ay, by);
    if (cy > dy) swap(cy, dy);
    by -= L, dy -= L;
    int mn = min(min(ay, by), min(cy, dy)), mx = max(max(ay, by), max(cy, dy)),
        z = mn + mx >> 1;
    p[0] = Point(vx[0], z), p[1] = Point(vx[0], z + L);
    p[2] = Point(vx[1], z), p[3] = Point(vx[1], z + L);
    upd();
    return;
  }
  if (cnty == 1) {
    int L = abs(vx[0] - vx[1]);
    p[0] = Point(vx[0], vy[0]), p[1] = Point(vx[1], vy[0]);
    p[2] = Point(vx[0], vy[0] - L), p[3] = Point(vx[1], vy[0] - L);
    upd();
    p[2] = Point(vx[0], vy[0] + L), p[3] = Point(vx[1], vy[0] + L);
    upd();
    return;
  }
  if (cnty == 2 && abs(vx[0] - vx[1]) == abs(vy[0] - vy[1])) {
    p[0] = Point(vx[0], vy[0]), p[1] = Point(vx[0], vy[1]),
    p[2] = Point(vx[1], vy[0]), p[3] = Point(vx[1], vy[1]);
    upd();
    return;
  }
}
inline void solve() {
  int i;
  Ans = inf;
  a[0].init(), a[1].init(), a[2].init(), a[3].init();
  ff = 0;
  for (i = 0; i < 16; ++i) solve(i);
  for (i = 0; i < 4; ++i) swap(a[i].x, a[i].y);
  ff = 1;
  for (i = 0; i < 16; ++i) solve(i);
  if (Ans >= inf)
    puts("-1");
  else
    printf("%d\n", Ans), ans[0].print(), ans[1].print(), ans[2].print(),
        ans[3].print();
}
int main() {
  int T;
  read(T);
  while (T--) solve();
  return 0;
}
