#include <bits/stdc++.h>
using namespace std;
template <typename T>
void get_int(T &x) {
  char t = getchar();
  bool neg = false;
  x = 0;
  for (; (t > '9' || t < '0') && t != '-'; t = getchar())
    ;
  if (t == '-') neg = true, t = getchar();
  for (; t <= '9' && t >= '0'; t = getchar()) x = x * 10 + t - '0';
  if (neg) x = -x;
}
template <typename T>
void print_int(T x) {
  if (x < 0) putchar('-'), x = -x;
  short t[20] = {}, sz = 0;
  while (x > 0) t[sz++] = x % 10, x /= 10;
  if (sz == 0) putchar('0');
  for (int i = sz - 1; i >= 0; i--) putchar('0' + t[i]);
}
const int inf = 0x3f3f3f3f;
const long long Linf = 1ll << 61;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
pair<int, int> t[4], a, b, c, d, ansx[4], cur[4];
int o[4], ansy, da, db, dc, dd;
int cal(pair<int, int> a, pair<int, int> b, int dir) {
  if (dir == 0 && a.first == b.first && a.second <= b.second)
    return b.second - a.second;
  else if (dir == 1 && a.first == b.first && a.second >= b.second)
    return a.second - b.second;
  else if (dir == 2 && a.second == b.second && a.first <= b.first)
    return b.first - a.first;
  else if (dir == 3 && a.second == b.second && a.first >= b.first)
    return a.first - b.first;
  else
    return inf;
}
pair<int, int> seg(pair<int, int> x, int len, int dir) {
  if (dir == 0)
    return make_pair(x.second, x.second + len);
  else if (dir == 1)
    return make_pair(x.second - len, x.second);
  else if (dir == 2)
    return make_pair(x.first, x.first + len);
  else
    return make_pair(x.first - len, x.first);
}
int go(int len, int x) {
  pair<int, int> sa = seg(a, x, da), sb = seg(b, x, db), sc = seg(c, x, dc),
                 sd = seg(d, x, dd);
  sa.first += len;
  sa.second += len;
  sd.first += len;
  sd.second += len;
  int mx = max(max(sa.first, sb.first), max(sc.first, sd.first)),
      mn = min(min(sa.second, sb.second), min(sc.second, sd.second));
  if (mx <= mn) return mx;
}
void check() {
  int len = inf;
  if (da > 1) {
    if (dd > 1) {
      if (len == inf || len == a.second - d.second)
        len = a.second - d.second;
      else
        return;
    } else if (dc > 1) {
      if (len == inf || len == a.second - c.second)
        len = a.second - c.second;
      else
        return;
    } else {
      if (len == inf || len == c.first - d.first)
        len = c.first - d.first;
      else
        return;
    }
  } else {
    if (db < 2) {
      if (len == inf || len == b.first - a.first)
        len = b.first - a.first;
      else
        return;
    } else if (dc < 2) {
      if (len == inf || len == c.first - a.first)
        len = c.first - a.first;
      else
        return;
    } else {
      if (len == inf || len == b.second - c.second)
        len = b.second - c.second;
      else
        return;
    }
  }
  if (len <= 0 || len == inf) return;
  if (da > 1 && dd < 2)
    cur[0] = make_pair(d.first, a.second);
  else if (da < 2 && db > 1)
    cur[0] = make_pair(a.first, b.second);
  else if (db > 1 && dc < 2)
    cur[0] = make_pair(c.first - len, b.second);
  else if (db < 2 && da > 1)
    cur[0] = make_pair(b.first - len, a.second);
  else if (dc > 1 && db < 2)
    cur[0] = make_pair(b.first - len, c.second + len);
  else if (dc < 2 && dd > 1)
    cur[0] = make_pair(c.first - len, d.second + len);
  else if (dd > 1 && da < 2)
    cur[0] = make_pair(a.first, d.second + len);
  else if (dd < 2 && dc > 1)
    cur[0] = make_pair(d.first, c.second + len);
  else {
    b.first -= len;
    c.first -= len;
    d.second += len;
    c.second += len;
    int mxx = max(max(a.first, b.first), max(c.first, d.first));
    int mxy = max(max(a.second, b.second), max(c.second, d.second));
    int mnx = min(min(a.first, b.first), min(c.first, d.first));
    int mny = min(min(a.second, b.second), min(c.second, d.second));
    cur[0] = make_pair(mxx + mnx >> 1, mxy + mny >> 1);
    b.first += len;
    c.first += len;
    d.second -= len;
    c.second -= len;
  }
  cur[1] = make_pair(cur[0].first + len, cur[0].second);
  cur[2] = make_pair(cur[0].first + len, cur[0].second - len);
  cur[3] = make_pair(cur[0].first, cur[0].second - len);
  int mx =
      max(max(max(cal(a, cur[0], da), cal(b, cur[1], db)), cal(c, cur[2], dc)),
          cal(d, cur[3], dd));
  if (mx < ansy) {
    ansy = mx;
    for (int i = 0; i < 4; i++) ansx[o[i]] = cur[i];
  }
}
void solve(int tc) {
  ansy = inf;
  for (int i = 0; i < 4; i++) get_int(t[i].first), get_int(t[i].second);
  for (int i = 0; i < 4; i++) o[i] = i;
  do {
    a = t[o[0]];
    b = t[o[1]];
    c = t[o[2]];
    d = t[o[3]];
    for (da = 0; da < 4; da++)
      for (db = 0; db < 4; db++)
        for (dc = 0; dc < 4; dc++)
          for (dd = 0; dd < 4; dd++) check();
  } while (next_permutation(o, o + 4));
  if (ansy == inf)
    puts("-1");
  else {
    print_int(ansy), puts("");
    for (int i = 0; i < 4; i++)
      printf("%d %d\n", ansx[i].first, ansx[i].second);
  }
}
int main() {
  int tc;
  get_int(tc);
  for (int i = 1; i <= tc; i++) solve(i);
  return 0;
}
