#include <bits/stdc++.h>
using namespace std;
int t, a[10], b[10], vi[10], ax[10], ay[10], nx[10], ny[10], ans, na, g[10],
    f[10], c[10];
void get(int dep, int x) {
  if (dep > 4) {
    if (x == 0) {
      if (a[g[1]] != a[g[2]] || a[g[3]] != a[g[4]] || a[g[1]] >= a[g[3]])
        return;
      if (b[g[1]] > b[g[2]] || b[g[3]] > b[g[4]]) return;
      int bc = a[g[3]] - a[g[1]];
      int ma = max(b[g[1]], max(b[g[3]], max(b[g[2]] - bc, b[g[4]] - bc)));
      int mi = min(b[g[1]], min(b[g[3]], min(b[g[2]] - bc, b[g[4]] - bc)));
      na = (ma - mi + 1) / 2;
      int p = mi + na + bc;
      for (int i = 1; i <= 4; i++)
        nx[g[i]] = a[g[i]], ny[g[i]] = p + (i % 2) * (-bc);
      if (na < ans) {
        ans = na;
        for (int i = 1; i <= 4; i++) ax[i] = nx[i], ay[i] = ny[i];
      }
      return;
    }
    if (x == 15) {
      if (b[g[1]] != b[g[2]] || b[g[3]] != b[g[4]] || b[g[1]] >= b[g[3]])
        return;
      if (a[g[1]] > a[g[2]] || a[g[3]] > a[g[4]]) return;
      int bc = b[g[3]] - b[g[1]];
      int ma = max(a[g[1]], max(a[g[3]], max(a[g[2]] - bc, a[g[4]] - bc)));
      int mi = min(a[g[1]], min(a[g[3]], min(a[g[2]] - bc, a[g[4]] - bc)));
      na = (ma - mi + 1) / 2;
      int p = mi + na + bc;
      for (int i = 1; i <= 4; i++)
        ny[g[i]] = b[g[i]], nx[g[i]] = p + (i % 2) * (-bc);
      if (na < ans) {
        ans = na;
        for (int i = 1; i <= 4; i++) ax[i] = nx[i], ay[i] = ny[i];
      }
      return;
    }
    int bc = -1;
    for (int i = 1; i <= 4; i++) {
      for (int j = i + 1; j <= 4; j++) {
        if (c[i] == c[j]) {
          if (c[i] == 0 && ((f[i] / 3) != (f[j] / 3))) bc = abs(b[i] - b[j]);
          if (c[i] == 1 && ((f[i] % 2) != (f[j] % 2))) bc = abs(a[i] - a[j]);
        }
      }
    }
    if (bc == 0) return;
    for (int i = 1; i <= 4; i++) {
      if (c[i] != c[g[1]] && i != g[1]) {
        if (c[g[1]] == 1) {
          nx[g[1]] = a[g[1]];
          if (f[i] == 2)
            ny[g[1]] = b[i];
          else
            ny[g[1]] = b[i] - bc;
        } else {
          ny[g[1]] = b[g[1]];
          if (f[i] == 3)
            nx[g[1]] = a[i];
          else
            nx[g[1]] = a[i] - bc;
        }
      }
    }
    int ma = 0;
    for (int i = 1; i <= 4; i++) {
      nx[i] = nx[g[1]] + bc * (f[i] % 2 == 0);
      ny[i] = ny[g[1]] + bc * (f[i] / 3);
      if (c[i] == 1 && a[i] != nx[i]) return;
      if (c[i] == 0 && b[i] != ny[i]) return;
      ma = max(ma, max(abs(a[i] - nx[i]), abs(b[i] - ny[i])));
    }
    if (ma < ans) {
      ans = ma;
      for (int i = 1; i <= 4; i++) ax[i] = nx[i], ay[i] = ny[i];
    }
  } else {
    for (int j = 1; j <= 4; j++) {
      if (vi[j]) {
        g[dep] = j;
        f[j] = dep;
        vi[j] = 0;
        get(dep + 1, x);
        vi[j] = 1;
      }
    }
  }
}
int main() {
  cin >> t;
  vi[4] = vi[1] = vi[2] = vi[3] = 1;
  while (t--) {
    ans = 1e9;
    for (int i = 1; i <= 4; i++) cin >> a[i] >> b[i];
    for (int i = 0; i < (1 << 4); i++) {
      for (int j = 1, k = i; j <= 4; j++, k /= 2) c[j] = k % 2;
      get(1, i);
    }
    if (ans == 1e9)
      puts("-1");
    else {
      cout << ans << endl;
      for (int i = 1; i <= 4; i++) cout << ax[i] << ' ' << ay[i] << endl;
    }
  }
  return 0;
}
