#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch - '0' < 0 || ch - '0' > 9) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch - '0' >= 0 && ch - '0' <= 9) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int T;
struct P {
  int x, y;
} p[5], com[5], ansx[5];
int a[5];
int X[5], top1, Y[5], top2;
int p1[5], topx1, p2[5], topx2;
int id[5], vis[5], ans = 1000000007;
void work(int x) {
  if (x > 4) {
    int res = 0;
    for (int i = 1; i <= 4; i++) {
      int d = id[i];
      if (p[i].x != com[d].x && p[i].y != com[d].y) return;
      res = max(res, abs(p[i].x - com[d].x) + abs(p[i].y - com[d].y));
    }
    if (res < ans) {
      ans = res;
      for (int i = 1; i <= 4; i++) ansx[i] = com[id[i]];
    }
    return;
  }
  for (int i = 1; i <= 4; i++) {
    if (!vis[i]) {
      id[x] = i;
      vis[i] = 1;
      work(x + 1);
      vis[i] = 0;
    }
  }
}
void solve() {
  top1 = top2 = 0;
  for (int i = 1; i <= 4; i++) {
    if (a[i] == 0)
      X[++top1] = p[i].x;
    else
      Y[++top2] = p[i].y;
  }
  sort(X + 1, X + top1 + 1);
  top1 = unique(X + 1, X + top1 + 1) - X - 1;
  sort(Y + 1, Y + top2 + 1);
  top2 = unique(Y + 1, Y + top2 + 1) - Y - 1;
  if (top1 == 2 && top2 == 2) {
    if (X[2] - X[1] != Y[2] - Y[1]) return;
    for (int i = 1; i <= 2; i++)
      for (int j = 1; j <= 2; j++) com[2 * i + j - 2] = (P){X[i], Y[j]};
    work(1);
  }
  if (top1 == 2 && top2 == 1) {
    int d = X[2] - X[1];
    for (int i = 1; i <= 2; i++) com[i] = (P){X[i], Y[1]};
    com[3] = (P){X[1], Y[1] - d};
    com[4] = (P){X[2], Y[1] - d};
    work(1);
    com[3] = (P){X[1], Y[1] + d};
    com[4] = (P){X[2], Y[1] + d};
    work(1);
  }
  if (top1 == 1 && top2 == 2) {
    int d = Y[2] - Y[1], cnt = 0;
    for (int i = 1; i <= 2; i++) com[i] = (P){X[1], Y[i]};
    com[3] = (P){X[1] - d, Y[1]};
    com[4] = (P){X[1] - d, Y[2]};
    work(1);
    com[3] = (P){X[1] + d, Y[1]};
    com[4] = (P){X[1] + d, Y[2]};
    work(1);
  }
  if (top1 == 2 && top2 == 0) {
    int d = X[2] - X[1];
    topx1 = topx2 = 0;
    for (int i = 1; i <= 4; i++) {
      if (p[i].x == X[1])
        p1[++topx1] = p[i].y;
      else
        p2[++topx2] = p[i].y;
    }
    if (p1[1] > p1[2]) swap(p1[1], p1[2]);
    if (p2[1] > p2[2]) swap(p2[1], p2[2]);
    int l = 0, r = 1e8, res;
    while (l <= r) {
      int mid = (l + r) / 2;
      int l1 = max(p1[1] - mid, p2[1] - mid),
          r1 = min(p1[1] + mid, p2[1] + mid);
      int l2 = max(p1[2] - mid, p2[2] - mid),
          r2 = min(p1[2] + mid, p2[2] + mid);
      if (l1 <= r1 && l2 <= r2 && max(l1 + d, l2) <= min(r1 + d, r2)) {
        res = mid;
        r = mid - 1;
      } else
        l = mid + 1;
    }
    int l1 = max(p1[1] - res, p2[1] - res), r1 = min(p1[1] + res, p2[1] + res);
    int l2 = max(p1[2] - res, p2[2] - res), r2 = min(p1[2] + res, p2[2] + res);
    int py = max(l1 + d, l2), px = py - d;
    int cnt = 0;
    for (int i = 1; i <= 2; i++)
      com[++cnt] = (P){X[i], px}, com[++cnt] = (P){X[i], py};
    work(1);
  }
  if (top1 == 0 && top2 == 2) {
    int d = Y[2] - Y[1];
    topx1 = topx2 = 0;
    for (int i = 1; i <= 4; i++) {
      if (p[i].y == Y[1])
        p1[++topx1] = p[i].x;
      else
        p2[++topx2] = p[i].x;
    }
    if (p1[1] > p1[2]) swap(p1[1], p1[2]);
    if (p2[1] > p2[2]) swap(p2[1], p2[2]);
    int l = 0, r = 1e8, res;
    while (l <= r) {
      int mid = (l + r) / 2;
      int l1 = max(p1[1] - mid, p2[1] - mid),
          r1 = min(p1[1] + mid, p2[1] + mid);
      int l2 = max(p1[2] - mid, p2[2] - mid),
          r2 = min(p1[2] + mid, p2[2] + mid);
      if (l1 <= r1 && l2 <= r2 && max(l1 + d, l2) <= min(r1 + d, r2)) {
        res = mid;
        r = mid - 1;
      } else
        l = mid + 1;
    }
    int l1 = max(p1[1] - res, p2[1] - res), r1 = min(p1[1] + res, p2[1] + res);
    int l2 = max(p1[2] - res, p2[2] - res), r2 = min(p1[2] + res, p2[2] + res);
    int py = max(l1 + d, l2), px = py - d;
    int cnt = 0;
    for (int i = 1; i <= 2; i++)
      com[++cnt] = (P){px, Y[i]}, com[++cnt] = (P){py, Y[i]};
    work(1);
  }
}
void dfs(int x) {
  if (x > 4) {
    solve();
    return;
  }
  a[x] = 0;
  dfs(x + 1);
  a[x] = 1;
  dfs(x + 1);
}
int main() {
  T = read();
  while (T--) {
    ans = 1000000007;
    for (int i = 1; i <= 4; i++) p[i].x = read(), p[i].y = read();
    dfs(1);
    if (ans == 1000000007)
      puts("-1");
    else {
      cout << ans << endl;
      for (int i = 1; i <= 4; i++) printf("%d %d\n", ansx[i].x, ansx[i].y);
    }
  }
  return 0;
}
