#include <bits/stdc++.h>
using namespace std;
struct pnt {
  int x, y, id;
  pnt(int x = 0, int y = 0, int id = -1) : x(x), y(y), id(id) {}
  void in(int i) {
    scanf("%d %d", &x, &y);
    id = i;
  }
  int dist(const pnt &p) { return abs(x + y - p.x - p.y); }
  void out() { printf("%d %d\n", x, y); }
} p[4];
const int inf = 2e9;
int ans;
pnt q[4], r[4];
void update() {
  int cur = 0;
  for (int i = 0; i < 4; i++) {
    if (r[i].x != p[i].x && r[i].y != p[i].y) return;
    cur = max(cur, r[i].dist(p[i]));
  }
  if (ans < cur) return;
  for (int i = 0; i < 4; i++) q[p[i].id] = r[i];
  ans = cur;
}
void solve(int i, int j, int k, int l) {
  r[l] = pnt(p[l].x, p[l].x + r[j].y - r[j].x);
  r[i] = pnt(r[l].x, r[j].y);
  r[k] = pnt(r[j].x, r[l].y);
  update();
  r[l] = pnt(p[l].y - r[j].y + r[j].x, p[l].y);
  r[i] = pnt(r[l].x, r[j].y);
  r[k] = pnt(r[j].x, r[l].y);
  update();
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    for (int i = 0; i < 4; i++) p[i].in(i);
    ans = inf;
    sort(p, p + 4, [&](pnt a, pnt b) {
      return pair<int, int>(a.x, a.y) < pair<int, int>(b.x, b.y);
    });
    if (p[0].x == p[1].x && p[2].x == p[3].x && p[1].x != p[2].x) {
      int d = abs(p[1].x - p[2].x);
      r[0].x = p[0].x;
      for (int i = 0; i < 4; i++) {
        for (int j = 0; j < i; j++) {
          int sum = p[i].y + p[j].y;
          if ((i ^ j) & 1)
            sum -= d;
          else if (i & 1)
            sum -= 2 * d;
          for (int k = 0; k < 2; k++) {
            r[0].y = sum >> 1;
            if (k) r[0].y = sum - r[0].y;
            r[1] = pnt(r[0].x, r[0].y + d);
            r[2] = pnt(r[0].x + d, r[0].y);
            r[3] = pnt(r[0].x + d, r[0].y + d);
            update();
          }
        }
      }
    }
    sort(p, p + 4, [&](pnt a, pnt b) {
      return pair<int, int>(a.y, a.x) < pair<int, int>(b.y, b.x);
    });
    if (p[0].y == p[1].y && p[2].y == p[3].y && p[1].y != p[2].y) {
      int d = abs(p[1].y - p[2].y);
      r[0].y = p[0].y;
      for (int i = 0; i < 4; i++) {
        for (int j = 0; j < i; j++) {
          int sum = p[i].x + p[j].x;
          if ((i ^ j) & 1)
            sum -= d;
          else if (i & 1)
            sum -= 2 * d;
          for (int k = 0; k < 2; k++) {
            r[0].x = sum >> 1;
            if (k) r[0].x = sum - r[0].x;
            r[2] = pnt(r[0].x, r[0].y + d);
            r[1] = pnt(r[0].x + d, r[0].y);
            r[3] = pnt(r[0].x + d, r[0].y + d);
            update();
          }
        }
      }
    }
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
        if (i != j) {
          int k = 0, l = 0;
          while (k == i || k == j) k++;
          l = k + 1;
          while (l == i || l == j) l++;
          pnt pt = pnt(p[j].x, p[i].y);
          r[j] = pt;
          solve(i, j, k, l);
          solve(i, j, l, k);
          r[i] = pt;
          solve(k, i, j, l);
          solve(l, i, j, k);
        }
    if (ans == inf)
      puts("-1");
    else {
      printf("%d\n", ans);
      for (int i = 0; i < 4; i++) q[i].out();
    }
  }
  return 0;
}
