#include <bits/stdc++.h>
using namespace std;
int x[5], y[5], p[5], d[5], lx, ly, lxz, lyz, rx, ry, rxz, ryz, ans, lz, rz,
    tx[5], ty[5];
void up(int &l, int &r, int L, int R) {
  l = max(l, L);
  r = min(r, R);
}
bool check(int t, int op = 0) {
  lx = ly = lxz = lyz = -5e8;
  lz = 1;
  rx = ry = rxz = ryz = rz = 5e8;
  for (int i = 1; i <= 4; i++) {
    int Lx, Rx, Ly, Ry;
    if (d[i] == 1) Lx = x[i], Rx = x[i] + t, Ly = Ry = y[i];
    if (d[i] == 2) Lx = Rx = x[i], Ly = y[i], Ry = y[i] + t;
    if (d[i] == 3) Lx = x[i] - t, Rx = x[i], Ly = Ry = y[i];
    if (d[i] == 4) Lx = Rx = x[i], Ly = y[i] - t, Ry = y[i];
    if (p[i] == 1 || p[i] == 4)
      up(lx, rx, Lx, Rx);
    else
      up(lxz, rxz, Lx, Rx);
    if (p[i] == 1 || p[i] == 2)
      up(ly, ry, Ly, Ry);
    else
      up(lyz, ryz, Ly, Ry);
  }
  if (lx > rx || ly > ry || lxz > rxz || lyz > ryz) return 0;
  up(lz, rz, lxz - rx, rxz - lx);
  up(lz, rz, lyz - ry, ryz - ly);
  if (lz <= rz) {
    if (op) {
      int az = lz, ax = max(lx, lxz - az), ay = max(ly, lyz - az);
      for (int i = 1; i <= 4; i++) {
        if (p[i] == 1 || p[i] == 4)
          tx[i] = ax;
        else
          tx[i] = ax + az;
        if (p[i] == 1 || p[i] == 2)
          ty[i] = ay;
        else
          ty[i] = ay + az;
      }
    }
    return 1;
  } else
    return 0;
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    for (int i = 1; i <= 4; i++) cin >> x[i] >> y[i];
    ans = 5e8;
    for (d[1] = 1; d[1] <= 4; d[1]++)
      for (d[2] = 1; d[2] <= 4; d[2]++)
        for (d[3] = 1; d[3] <= 4; d[3]++)
          for (d[4] = 1; d[4] <= 4; d[4]++) {
            for (int i = 1; i <= 4; i++) p[i] = i;
            do {
              int l = 0, r = ans;
              while (l < r) {
                int mid = (l + r) >> 1;
                check(mid) ? r = mid : l = mid + 1;
              }
              if (r < ans) {
                ans = r;
                check(r, 1);
              }
            } while (next_permutation(p + 1, p + 4 + 1));
          }
    if (ans == 5e8)
      cout << -1 << '\n';
    else {
      cout << ans << '\n';
      for (int i = 1; i <= 4; i++) cout << tx[i] << ' ' << ty[i] << '\n';
    }
  }
  return 0;
}
