#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f = ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return f ? -x : x;
}
const int INF = 1e9;
struct Point {
  int x, y;
  Point() {}
  Point(int _x, int _y) { x = _x, y = _y; }
  Point rot() { return Point(-y, x); }
  void rots(int x) {
    while (x--) (*this) = (*this).rot();
  }
} p[4];
int id[4];
pair<int, vector<Point> > ans;
pair<int, vector<Point> > solve(int base, Point d, int flag) {
  pair<int, vector<Point> > res;
  res.first = INF;
  int a = -1;
  if (flag == 0)
    a = p[id[(base + 2) % 4]].x - d.x;
  else
    a = p[id[(base + 2) % 4]].y - d.y;
  if (a <= 0) return res;
  res.second.resize(4);
  int mx = 0;
  for (int i = (0); i <= (3); i++) {
    Point t = d;
    if (i & 2) t.x += a;
    if ((i >> 1) ^ (i & 1)) t.y += a;
    int ID = id[(base + i) % 4];
    if (p[ID].x != t.x && p[ID].y != t.y) return res;
    mx = max(mx, abs(t.x - p[ID].x) + abs(t.y - p[ID].y));
    res.second[ID] = t;
  }
  res.first = mx;
  return res;
}
pair<int, vector<Point> > solve2(int base) {
  pair<int, vector<Point> > res;
  res.first = INF;
  if (p[id[(base + 0) % 4]].x != p[id[(base + 1) % 4]].x) return res;
  if (p[id[(base + 2) % 4]].x != p[id[(base + 3) % 4]].x) return res;
  int a = p[id[(base + 2) % 4]].x - p[id[(base + 0) % 4]].x;
  if (a <= 0) return res;
  int L = 0, R = 2e8, mid, ans = R;
  int py[4];
  for (int i = (0); i <= (3); i++) py[i] = p[id[(base + i) % 4]].y;
  while (L <= R) {
    mid = (L + R) >> 1;
    int flag = 1;
    if (py[1] - py[0] - mid * 2 > a || py[2] - py[3] - mid * 2 > a)
      flag = 0;
    else {
      int a0 = max(py[0] - mid, py[1] - mid - a),
          a1 = min(py[0] + mid, py[1] + mid - a);
      int b0 = max(py[3] - mid, py[2] - mid - a),
          b1 = min(py[3] + mid, py[2] + mid - a);
      if (max(a0, b0) > min(a1, b1)) flag = 0;
    }
    if (flag)
      R = mid - 1, ans = mid;
    else
      L = mid + 1;
  }
  mid = ans;
  int a0 = max(py[0] - mid, py[1] - mid - a),
      a1 = min(py[0] + mid, py[1] + mid - a);
  int b0 = max(py[3] - mid, py[2] - mid - a),
      b1 = min(py[3] + mid, py[2] + mid - a);
  res.first = ans;
  res.second.resize(4);
  int y = max(a0, b0);
  for (int i = (0); i <= (3); i++) {
    int ID = id[(base + i) % 4];
    Point now = Point(p[ID].x, y);
    if ((i >> 1) ^ (i & 1)) now.y += a;
    res.second[ID] = now;
  }
  return res;
}
void Solve() {
  for (int i = (0); i <= (3); i++) p[i].x = read(), p[i].y = read(), id[i] = i;
  ans.first = INF, ans.second.clear();
  do {
    for (int i = (0); i <= (3); i++) {
      for (int f = (0); f <= (1); f++) {
        {
          pair<int, vector<Point> > tmp =
              solve(i, Point(p[id[(i + 1) % 4]].x, p[id[i]].y), f);
          for (auto &j : tmp.second) j.rots(4 - i);
          if (tmp.first < ans.first) ans = tmp;
        }
        {
          pair<int, vector<Point> > tmp =
              solve(i, Point(p[id[i]].x, p[id[(i + 3) % 4]].y), f);
          for (auto &j : tmp.second) j.rots(4 - i);
          if (tmp.first < ans.first) ans = tmp;
        }
      }
      {
        pair<int, vector<Point> > tmp = solve2(i);
        for (auto &j : tmp.second) j.rots(4 - i);
        if (tmp.first < ans.first) ans = tmp;
      }
      for (int j = (0); j <= (3); j++) p[j].rots(1);
    }
  } while (next_permutation(id, id + 4));
  if (ans.first == INF) ans.first = -1;
  cout << ans.first << endl;
  if (ans.first != -1)
    for (auto i : ans.second) cout << i.x << " " << i.y << endl;
}
int main() {
  int T = read();
  while (T--) Solve();
  return 0;
}
