#include <bits/stdc++.h>
using namespace std;
const int MAXSIZE = 10000020;
const int INF = 0x7f7f7f7f;
int bufpos;
char buf[MAXSIZE];
void init() {
  buf[fread(buf, 1, MAXSIZE, stdin)] = '\0';
  bufpos = 0;
}
int readint() {
  bool isneg;
  int val = 0;
  for (; !isdigit(buf[bufpos]) && buf[bufpos] != '-'; bufpos++)
    ;
  bufpos += (isneg = buf[bufpos] == '-');
  for (; isdigit(buf[bufpos]); bufpos++) val = val * 10 + buf[bufpos] - '0';
  return isneg ? -val : val;
}
char readchar() {
  for (; isspace(buf[bufpos]); bufpos++)
    ;
  return buf[bufpos++];
}
int readstr(char* s) {
  int cur = 0;
  for (; isspace(buf[bufpos]); bufpos++)
    ;
  for (; !isspace(buf[bufpos]); bufpos++) s[cur++] = buf[bufpos];
  s[cur] = '\0';
  return cur;
}
struct point {
  int x, y;
} a[4], b[4], qwq[4];
int x[1000002], y[1000002], d[1000002];
int p[4];
int ans = INF;
int dx[4] = {0, 1, 0, 1};
int dy[4] = {0, 0, 1, 1};
inline int asb(int x) {
  if (x < 0) return -x;
  return x;
}
int marisa[24][4];
void work(int x, int y, int d) {
  for (int o = 0; o < 24; o++) {
    int* p = marisa[o];
    int tmp = 0;
    for (int i = 0; i < 4; i++) {
      int tx = x + dx[p[i]] * d, ty = y + dy[p[i]] * d;
      if (tx != a[i].x && ty != a[i].y) goto hell;
      b[i] = (point){tx, ty};
      tmp = max(tmp, asb(a[i].x - tx) + asb(a[i].y - ty));
    }
    if (tmp < ans) {
      ans = tmp;
      for (int i = 0; i < 4; i++) qwq[i] = b[i];
    }
  hell:;
  }
}
int main() {
  init();
  int T = readint();
  for (int i = 0; i < 4; i++) marisa[0][i] = i;
  for (int i = 1; i < 24; i++) {
    memcpy(marisa[i], marisa[i - 1], 16);
    next_permutation(marisa[i], marisa[i] + 4);
  }
  while (T--) {
    int cd = 0;
    for (int i = 0; i < 4; i++) a[i].x = readint(), a[i].y = readint();
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
        if (a[i].x > a[j].x) {
          d[++cd] = a[i].x - a[j].x;
        }
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
        if (a[i].y > a[j].y) {
          d[++cd] = a[i].y - a[j].y;
        }
    sort(d + 1, d + cd + 1);
    cd = unique(d + 1, d + cd + 1) - d - 1;
    ans = INF;
    for (int i = 1; i <= cd; i++) {
      int cx = 0, cy = 0;
      for (int j = 0; j < 4; j++)
        x[++cx] = a[j].x, x[++cx] = a[j].x + d[i], x[++cx] = a[j].x - d[i];
      for (int j = 0; j < 4; j++)
        y[++cy] = a[j].y, y[++cy] = a[j].y + d[i], y[++cy] = a[j].y - d[i];
      sort(x + 1, x + cx + 1);
      cx = unique(x + 1, x + cx + 1) - x - 1;
      sort(y + 1, y + cy + 1);
      cy = unique(y + 1, y + cy + 1) - y - 1;
      int now = cx;
      for (int j = 1; j <= now; j++)
        for (int k = 1; k < j; k++) x[++cx] = (x[k] + x[j]) / 2;
      now = cy;
      for (int j = 1; j <= now; j++)
        for (int k = 1; k < j; k++) y[++cy] = (y[k] + y[j]) / 2;
      sort(x + 1, x + cx + 1);
      cx = unique(x + 1, x + cx + 1) - x - 1;
      sort(y + 1, y + cy + 1);
      cy = unique(y + 1, y + cy + 1) - y - 1;
      for (int j = 1; j <= cx; j++)
        for (int k = 1; k <= cy; k++) {
          work(x[j], y[k], d[i]);
        }
    }
    if (ans == INF) {
      puts("-1");
      continue;
    }
    printf("%d\n", ans);
    for (int i = 0; i < 4; i++) printf("%d %d\n", qwq[i].x, qwq[i].y);
  }
}
