#include <bits/stdc++.h>
using namespace std;
const int N = 5;
struct cs {
  int x, y;
} a[N], b[N], c[N], d[1000];
int e[N], w[N];
bool vi[N];
int n, m, top, ans;
void fuck(cs a, cs b) {
  if (a.x != b.x && a.y != b.y) {
    d[++top].x = a.x;
    d[top].y = b.y;
    d[++top].x = b.x;
    d[top].y = a.y;
  }
}
void dfs(int k, int now) {
  if (now >= ans) return;
  if (k == 5) {
    for (int i = 1; i <= 4; i++) c[i] = b[e[i]];
    ans = now;
    return;
  }
  for (int i = 1; i <= 4; i++)
    if (a[i].x == b[k].x || a[i].y == b[k].y)
      if (!vi[i]) {
        vi[i] = 1;
        e[i] = k;
        dfs(k + 1, max(now, max(abs(a[i].x - b[k].x), abs(a[i].y - b[k].y))));
        vi[i] = 0;
      }
}
void jyz(int k) {
  for (int i = 1; i <= top; i++) {
    b[1].x = d[i].x;
    b[1].y = d[i].y;
    b[2].x = d[i].x + k;
    b[2].y = d[i].y;
    b[3].x = d[i].x;
    b[3].y = d[i].y + k;
    b[4].x = d[i].x + k;
    b[4].y = d[i].y + k;
    dfs(1, 0);
    b[1].x = d[i].x;
    b[1].y = d[i].y;
    b[2].x = d[i].x - k;
    b[2].y = d[i].y;
    b[3].x = d[i].x;
    b[3].y = d[i].y + k;
    b[4].x = d[i].x - k;
    b[4].y = d[i].y + k;
    dfs(1, 0);
    b[1].x = d[i].x;
    b[1].y = d[i].y;
    b[2].x = d[i].x + k;
    b[2].y = d[i].y;
    b[3].x = d[i].x;
    b[3].y = d[i].y - k;
    b[4].x = d[i].x + k;
    b[4].y = d[i].y - k;
    dfs(1, 0);
    b[1].x = d[i].x;
    b[1].y = d[i].y;
    b[2].x = d[i].x - k;
    b[2].y = d[i].y;
    b[3].x = d[i].x;
    b[3].y = d[i].y - k;
    b[4].x = d[i].x - k;
    b[4].y = d[i].y - k;
    dfs(1, 0);
  }
}
void noip() {
  for (int i = 1; i <= 4; i++) e[i] = a[i].y;
  sort(e + 1, e + 5);
  if (e[1] != e[2] || e[3] != e[4]) return;
  int D = e[3] - e[2], a1 = 0, a2 = 0, b1 = 0, b2 = 0;
  for (int i = 1; i <= 4; i++)
    if (a[i].y == e[1])
      if (a1)
        a2 = a[i].x;
      else
        a1 = a[i].x;
    else if (b1)
      b2 = a[i].x;
    else
      b1 = a[i].x;
  if (a1 > a2) swap(a1, a2);
  a2 -= D;
  if (a1 > a2) swap(a1, a2);
  if (b1 > b2) swap(b1, b2);
  b2 -= D;
  if (b1 > b2) swap(b1, b2);
  a1 = min(a1, b1);
  a2 = max(a2, b2);
  d[++top].y = e[1];
  d[top].x = (a2 + a1) / 2;
}
void NOIP() {
  for (int i = 1; i <= 4; i++) e[i] = a[i].x;
  sort(e + 1, e + 5);
  if (e[1] != e[2] || e[3] != e[4]) return;
  int D = e[3] - e[2], a1 = 0, a2 = 0, b1 = 0, b2 = 0;
  for (int i = 1; i <= 4; i++)
    if (a[i].x == e[1])
      if (a1)
        a2 = a[i].y;
      else
        a1 = a[i].y;
    else if (b1)
      b2 = a[i].y;
    else
      b1 = a[i].y;
  if (a1 > a2) swap(a1, a2);
  a2 -= D;
  if (a1 > a2) swap(a1, a2);
  if (b1 > b2) swap(b1, b2);
  b2 -= D;
  if (b1 > b2) swap(b1, b2);
  a1 = min(a1, b1);
  a2 = max(a2, b2);
  d[++top].x = e[1];
  d[top].y = (a2 + a1) / 2;
}
int main() {
  scanf("%d", &n);
  while (n--) {
    top = 0;
    ans = 1e9;
    for (int i = 1; i <= 4; i++)
      scanf("%d%d", &a[i].x, &a[i].y), d[++top] = a[i];
    noip();
    NOIP();
    for (int i = 1; i <= 4; i++)
      for (int j = i + 1; j <= 4; j++) fuck(a[i], a[j]);
    for (int i = 1; i <= 4; i++)
      for (int j = i + 1; j <= 4; j++)
        jyz(abs(a[i].x - a[j].x)), jyz(abs(a[i].y - a[j].y));
    if (ans == 1e9)
      puts("-1");
    else {
      printf("%d\n", ans);
      for (int i = 1; i <= 4; i++) printf("%d %d\n", c[i].x, c[i].y);
    }
  }
}
