#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int k = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    k = k * 10 + ch - '0';
    ch = getchar();
  }
  return k * f;
}
struct ppap {
  int x, y;
} a[5], b[5], as[5], d[30];
int cnt = 0, ans;
inline void gz(int x, int y) {
  if (a[x].x != a[y].x && a[x].y != a[y].y) {
    d[++cnt] = (ppap){a[x].x, a[y].y};
    d[++cnt] = (ppap){a[y].x, a[x].y};
  }
}
int p[30];
inline void heng() {
  for (int i = 1; i <= 4; i++) p[i] = a[i].y;
  sort(p + 1, p + 5);
  if (p[1] != p[2] || p[3] != p[4]) return;
  int D = p[3] - p[2], x1 = 0, y1 = 0, x2 = 0, y2 = 0;
  for (int i = 1; i <= 4; i++) {
    if (a[i].y == p[1]) {
      if (x1)
        x2 = a[i].x;
      else
        x1 = a[i].x;
    } else {
      if (y1)
        y2 = a[i].x;
      else
        y1 = a[i].x;
    }
  }
  int X1 = min(min(x1, x2), max(x1, x2) - D),
      X2 = max(min(x1, x2), max(x1, x2) - D);
  int Y1 = min(min(y1, y2), max(y1, y2) - D),
      Y2 = max(min(y1, y2), max(y1, y2) - D);
  int X = min(X1, Y1), Y = max(X2, Y2);
  d[++cnt] = (ppap){(X + Y) / 2, p[1]};
}
inline void shu() {
  for (int i = 1; i <= 4; i++) p[i] = a[i].x;
  sort(p + 1, p + 5);
  if (p[1] != p[2] || p[3] != p[4]) return;
  int D = p[3] - p[2], x1 = 0, y1 = 0, x2 = 0, y2 = 0;
  for (int i = 1; i <= 4; i++) {
    if (a[i].x == p[1]) {
      if (x1)
        x2 = a[i].y;
      else
        x1 = a[i].y;
    } else {
      if (y1)
        y2 = a[i].y;
      else
        y1 = a[i].y;
    }
  }
  int X1 = min(min(x1, x2), max(x1, x2) - D),
      X2 = max(min(x1, x2), max(x1, x2) - D);
  int Y1 = min(min(y1, y2), max(y1, y2) - D),
      Y2 = max(min(y1, y2), max(y1, y2) - D);
  int X = min(X1, Y1), Y = max(X2, Y2);
  d[++cnt] = (ppap){p[1], (X + Y) / 2};
}
bool vis[30];
inline void dfs(int x, int maxx) {
  if (maxx > ans) return;
  if (x == 5) {
    for (int i = 1; i <= 4; i++) as[i] = b[p[i]];
    ans = maxx;
    return;
  }
  for (int i = 1; i <= 4; i++)
    if (a[i].x == b[x].x || a[i].y == b[x].y) {
      if (vis[i]) continue;
      p[i] = x;
      vis[i] = 1;
      dfs(x + 1, max(maxx, max(abs(a[i].x - b[x].x), abs(a[i].y - b[x].y))));
      vis[i] = 0;
    }
}
inline void work(int x) {
  for (int i = 1; i <= cnt; i++) {
    b[1] = (ppap){d[i].x, d[i].y};
    b[2] = (ppap){d[i].x + x, d[i].y};
    b[3] = (ppap){d[i].x, d[i].y + x};
    b[4] = (ppap){d[i].x + x, d[i].y + x};
    dfs(1, 0);
    b[1] = (ppap){d[i].x, d[i].y};
    b[2] = (ppap){d[i].x - x, d[i].y};
    b[3] = (ppap){d[i].x, d[i].y + x};
    b[4] = (ppap){d[i].x - x, d[i].y + x};
    dfs(1, 0);
    b[1] = (ppap){d[i].x, d[i].y};
    b[2] = (ppap){d[i].x + x, d[i].y};
    b[3] = (ppap){d[i].x, d[i].y - x};
    b[4] = (ppap){d[i].x + x, d[i].y - x};
    dfs(1, 0);
    b[1] = (ppap){d[i].x, d[i].y};
    b[2] = (ppap){d[i].x - x, d[i].y};
    b[3] = (ppap){d[i].x, d[i].y - x};
    b[4] = (ppap){d[i].x - x, d[i].y - x};
    dfs(1, 0);
  }
}
int main() {
  int T = read();
  while (T--) {
    cnt = 0;
    ans = 1e9;
    for (int i = 1; i <= 4; i++)
      a[i].x = read(), a[i].y = read(), d[++cnt] = a[i];
    heng();
    shu();
    for (int i = 1; i <= 4; i++)
      for (int j = i + 1; j <= 4; j++) gz(i, j);
    for (int i = 1; i <= 4; i++)
      for (int j = i + 1; j <= 4; j++)
        work(abs(a[i].x - a[j].x)), work(a[i].y - a[j].y);
    if (ans == 1e9) {
      puts("-1");
      continue;
    }
    printf("%d\n", ans);
    for (int i = 1; i <= 4; i++) printf("%d %d\n", as[i].x, as[i].y);
  }
  return 0;
}
