#include <bits/stdc++.h>
using namespace std;
const int maxn = 5;
const int INF = 0x3f3f3f3f;
int T, ret, now, p[maxn], q[maxn], f[maxn];
pair<int, int> a[maxn], b[maxn], ans[maxn];
map<int, bool> Mapx, Mapy;
inline void Fuck() {
  int Minx = INF, Miny = INF, Maxx = -INF, Maxy = -INF;
  for (int i = (1), _end_ = (4); i <= _end_; ++i) {
    Minx = min(Minx, b[p[i]].first);
    Miny = min(Miny, b[p[i]].second);
    Maxx = max(Maxx, b[p[i]].first);
    Maxy = max(Maxy, b[p[i]].second);
  }
  int num1 = 0, num2 = 0;
  for (int i = (1), _end_ = (4); i <= _end_; ++i) {
    if (b[i].first == Minx) ++num1;
    if (b[i].second == Miny) ++num2;
    if (b[i].first != Minx && b[i].first != Maxx) return;
    if (b[i].second != Miny && b[i].second != Maxy) return;
  }
  if (num1 != 2 || num2 != 2 || Maxx - Minx != Maxy - Miny) return;
  now = 0;
  for (int i = (1), _end_ = (4); i <= _end_; ++i) {
    if (a[i].first != b[p[i]].first && a[i].second != b[p[i]].second) return;
    if (a[i].first != b[p[i]].first)
      now = max(now, abs(a[i].first - b[p[i]].first));
    if (a[i].second != b[p[i]].second)
      now = max(now, abs(a[i].second - b[p[i]].second));
  }
  if (now >= ret) return;
  ret = now;
  for (int i = (1), _end_ = (4); i <= _end_; ++i) ans[i] = b[p[i]];
}
inline void Maintain() {
  for (int i = (1), _end_ = (4); i <= _end_; ++i) p[i] = i;
  do {
    Fuck();
  } while (next_permutation(p + 1, p + 4 + 1));
}
inline void Solve() {
  for (int i = (0), _end_ = ((1 << 4) - 1); i <= _end_; ++i) {
    Mapx.clear();
    Mapy.clear();
    for (int j = (1), _end_ = (4); j <= _end_; ++j)
      if ((i >> j - 1) & 1)
        Mapx[a[j].first] = true;
      else
        Mapy[a[j].second] = true;
    vector<int> px, py;
    for (auto it : Mapx) px.push_back(it.first);
    for (auto it : Mapy) py.push_back(it.first);
    if (px.size() > 2 || py.size() > 2) continue;
    if (px.size() == 2 && py.size() == 2) {
      b[1] = pair<int, int>(px[0], py[0]);
      b[2] = pair<int, int>(px[0], py[1]);
      b[3] = pair<int, int>(px[1], py[0]);
      b[4] = pair<int, int>(px[1], py[1]);
      Maintain();
    }
    if (px.size() == 2 && py.size() == 1) {
      int first = px[1] - px[0], second = py[0];
      b[1] = pair<int, int>(px[0], second);
      b[2] = pair<int, int>(px[0], second + first);
      b[3] = pair<int, int>(px[1], second);
      b[4] = pair<int, int>(px[1], second + first);
      Maintain();
      b[1] = pair<int, int>(px[0], second);
      b[2] = pair<int, int>(px[0], second - first);
      b[3] = pair<int, int>(px[1], second);
      b[4] = pair<int, int>(px[1], second - first);
      Maintain();
    }
    if (px.size() == 1 && py.size() == 2) {
      int first = px[0], second = py[1] - py[0];
      b[1] = pair<int, int>(first, py[0]);
      b[2] = pair<int, int>(first + second, py[0]);
      b[3] = pair<int, int>(first, py[1]);
      b[4] = pair<int, int>(first + second, py[1]);
      Maintain();
      b[1] = pair<int, int>(first, py[0]);
      b[2] = pair<int, int>(first - second, py[0]);
      b[3] = pair<int, int>(first, py[1]);
      b[4] = pair<int, int>(first - second, py[1]);
      Maintain();
    }
    if (px.size() == 2 && py.size() == 0) {
      int d = px[1] - px[0];
      for (int i = (1), _end_ = (4); i <= _end_; ++i) q[i] = i;
      do {
        f[1] = a[q[1]].second;
        f[2] = a[q[2]].second;
        f[3] = a[q[3]].second - d;
        f[4] = a[q[4]].second - d;
        int Min = INF, Max = -INF;
        for (int i = (1), _end_ = (4); i <= _end_; ++i) {
          Min = min(Min, f[i]);
          Max = max(Max, f[i]);
        }
        int first = (Max + Min) / 2;
        b[1] = pair<int, int>(px[0], first);
        b[2] = pair<int, int>(px[1], first);
        b[3] = pair<int, int>(px[0], first + d);
        b[4] = pair<int, int>(px[1], first + d);
        Maintain();
      } while (next_permutation(q + 1, q + 4 + 1));
    }
    if (px.size() == 0 && py.size() == 2) {
      int d = py[1] - py[0];
      for (int i = (1), _end_ = (4); i <= _end_; ++i) q[i] = i;
      do {
        f[1] = a[q[1]].first;
        f[2] = a[q[2]].first;
        f[3] = a[q[3]].first - d;
        f[4] = a[q[4]].first - d;
        int Min = INF, Max = -INF;
        for (int i = (1), _end_ = (4); i <= _end_; ++i) {
          Min = min(Min, f[i]);
          Max = max(Max, f[i]);
        }
        int first = (Max + Min) / 2;
        b[1] = pair<int, int>(first, py[0]);
        b[2] = pair<int, int>(first, py[1]);
        b[3] = pair<int, int>(first + d, py[0]);
        b[4] = pair<int, int>(first + d, py[1]);
        Maintain();
      } while (next_permutation(q + 1, q + 4 + 1));
    }
  }
}
int main() {
  scanf("%d", &T);
  while (T--) {
    for (int i = (1), _end_ = (4); i <= _end_; ++i)
      scanf("%d%d", &a[i].first, &a[i].second);
    ret = INF;
    Solve();
    if (ret == INF)
      puts("-1");
    else {
      printf("%d\n", ret);
      for (int i = (1), _end_ = (4); i <= _end_; ++i)
        printf("%d %d\n", ans[i].first, ans[i].second);
    }
  }
  return 0;
}
