#include <bits/stdc++.h>
using namespace std;
int main() {
  int tn;
  assert(scanf("%d", &tn) == 1);
  for (int tt = 0; tt < tn; tt++) {
    int n = 4;
    int x[n], y[n];
    for (int i = 0; i < n; i++) assert(scanf("%d%d", &x[i], &y[i]) == 2);
    bool ans_ok = false;
    int ans = 0, ans_x[4], ans_y[4];
    vector<int> ds;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) {
        if (x[i] != x[j]) ds.push_back(abs(x[i] - x[j]));
        if (y[i] != y[j]) ds.push_back(abs(y[i] - y[j]));
      }
    sort(ds.begin(), ds.end());
    for (int di = 0; di < (int)ds.size(); di++) {
      if (di != 0 && ds[di] == ds[di - 1]) continue;
      int d = ds[di];
      vector<int> xs, ys;
      for (int i = 0; i < n; i++) {
        xs.push_back(x[i] - d);
        xs.push_back(x[i]);
        xs.push_back(x[i] + d);
        ys.push_back(y[i] - d);
        ys.push_back(y[i]);
        ys.push_back(y[i] + d);
        for (int j = 0; j < n; j++) {
          if (x[i] != x[j]) {
            xs.push_back((x[i] + x[j] - d) / 2 - d);
            xs.push_back((x[i] + x[j]) / 2 - d);
            xs.push_back((x[i] + x[j] + d) / 2 - d);
            xs.push_back((x[i] + x[j] - d + 1) / 2 - d);
            xs.push_back((x[i] + x[j] + 1) / 2 - d);
            xs.push_back((x[i] + x[j] + d + 1) / 2 - d);
            xs.push_back((x[i] + x[j] - d) / 2);
            xs.push_back((x[i] + x[j]) / 2);
            xs.push_back((x[i] + x[j] + d) / 2);
            xs.push_back((x[i] + x[j] - d + 1) / 2);
            xs.push_back((x[i] + x[j] + 1) / 2);
            xs.push_back((x[i] + x[j] + d + 1) / 2);
            xs.push_back((x[i] + x[j] - d) / 2 + d);
            xs.push_back((x[i] + x[j]) / 2 + d);
            xs.push_back((x[i] + x[j] + d) / 2 + d);
            xs.push_back((x[i] + x[j] - d + 1) / 2 + d);
            xs.push_back((x[i] + x[j] + 1) / 2 + d);
            xs.push_back((x[i] + x[j] + d + 1) / 2 + d);
          }
          if (y[i] != y[j]) {
            ys.push_back((y[i] + y[j] - d) / 2 - d);
            ys.push_back((y[i] + y[j]) / 2 - d);
            ys.push_back((y[i] + y[j] + d) / 2 - d);
            ys.push_back((y[i] + y[j] - d + 1) / 2 - d);
            ys.push_back((y[i] + y[j] + 1) / 2 - d);
            ys.push_back((y[i] + y[j] + d + 1) / 2 - d);
            ys.push_back((y[i] + y[j] - d) / 2);
            ys.push_back((y[i] + y[j]) / 2);
            ys.push_back((y[i] + y[j] + d) / 2);
            ys.push_back((y[i] + y[j] - d + 1) / 2);
            ys.push_back((y[i] + y[j] + 1) / 2);
            ys.push_back((y[i] + y[j] + d + 1) / 2);
            ys.push_back((y[i] + y[j] - d) / 2 + d);
            ys.push_back((y[i] + y[j]) / 2 + d);
            ys.push_back((y[i] + y[j] + d) / 2 + d);
            ys.push_back((y[i] + y[j] - d + 1) / 2 + d);
            ys.push_back((y[i] + y[j] + 1) / 2 + d);
            ys.push_back((y[i] + y[j] + d + 1) / 2 + d);
          }
        }
      }
      sort(xs.begin(), xs.end());
      sort(ys.begin(), ys.end());
      for (int xi = 0; xi < (int)xs.size(); xi++) {
        if (xi != 0 && xs[xi] == xs[xi - 1]) continue;
        int tx[4] = {xs[xi], xs[xi] + d, xs[xi] + d, xs[xi]};
        for (int yi = 0; yi < (int)ys.size(); yi++) {
          if (yi != 0 && ys[yi] == ys[yi - 1]) continue;
          int ty[4] = {ys[yi], ys[yi], ys[yi] + d, ys[yi] + d};
          int p[n];
          for (int i = 0; i < n; i++) p[i] = i;
          do {
            bool ok = true;
            int res = 0;
            for (int i = 0; i < n; i++) {
              if (x[p[i]] != tx[i] && y[p[i]] != ty[i]) {
                ok = false;
                break;
              }
              res = max(res, abs(x[p[i]] - tx[i]) + abs(y[p[i]] - ty[i]));
            }
            if (!ok) continue;
            if (!ans_ok || res < ans) {
              ans_ok = true;
              ans = res;
              for (int i = 0; i < n; i++) {
                ans_x[p[i]] = tx[i];
                ans_y[p[i]] = ty[i];
              }
            }
          } while (next_permutation(p, p + n));
        }
      }
    }
    if (ans_ok) {
      printf("%d\n", ans);
      for (int i = 0; i < n; i++) printf("%d %d\n", ans_x[i], ans_y[i]);
    } else
      puts("-1");
  }
  return 0;
}
