#include <bits/stdc++.h>
using namespace std;
const pair<int, int> INVALID(1e9, -1e9);
pair<int, int> merge(pair<int, int> p, pair<int, int> q) {
  return pair<int, int>(max(p.first, q.first), min(p.second, q.second));
}
bool in(pair<int, int> p, int q) { return p.first <= q && q <= p.second; }
pair<int, int> pt[4], ans[4], px[4], py[4];
int T, id[4];
bool work() {
  for (int i = 0; i < 4; ++i) id[i] = i;
  do {
    int x1, y1, L = 0;
    if (pt[id[0]].second < pt[id[1]].second) {
      int dst = pt[id[1]].second - pt[id[0]].second;
      pair<int, int> rx = merge(px[id[0]], px[id[1]]);
      rx.first += dst;
      rx.second += dst;
      for (int i = 2; i < 4; ++i)
        if (pt[id[i]].second == pt[id[3 - i]].second)
          rx = merge(rx, px[id[i]]);
        else if (in(py[id[i]], pt[id[3 - i]].second))
          rx = merge(rx, pair<int, int>(pt[id[i]].first, pt[id[i]].first));
        else
          rx = INVALID;
      if (rx.first <= rx.second) {
        x1 = rx.first - dst;
        y1 = pt[id[0]].second;
        L = dst;
      }
    }
    if (!L && in(px[id[0]], pt[id[1]].first)) {
      x1 = pt[id[1]].first;
      y1 = pt[id[0]].second;
      pair<int, int> ry = py[id[1]],
                     rx = pt[id[3]].second == y1
                              ? px[id[3]]
                              : (in(py[id[3]], y1)
                                     ? pair<int, int>(pt[id[3]].first,
                                                      pt[id[3]].first)
                                     : INVALID);
      ry.first = max(ry.first - y1, 1);
      ry.second -= y1;
      rx.first = max(rx.first - x1, 1);
      rx.second -= x1;
      rx = merge(rx, ry);
      if (in(rx, pt[id[2]].first - x1) &&
          in(py[id[2]], y1 + (pt[id[2]].first - x1)))
        L = pt[id[2]].first - x1;
      if (in(rx, pt[id[2]].second - y1) &&
          in(px[id[2]], x1 + (pt[id[2]].second - y1)))
        L = pt[id[2]].second - y1;
    }
    if (L) {
      ans[id[0]] = pair<int, int>(x1, y1);
      ans[id[1]] = pair<int, int>(x1, y1 + L);
      ans[id[2]] = pair<int, int>(x1 + L, y1 + L);
      ans[id[3]] = pair<int, int>(x1 + L, y1);
      return 1;
    }
  } while (next_permutation(id, id + 4));
  return 0;
}
bool check(int mid) {
  for (int i = 0; i < 4; ++i) {
    px[i] = pair<int, int>(pt[i].first - mid, pt[i].first + mid);
    py[i] = pair<int, int>(pt[i].second - mid, pt[i].second + mid);
  }
  if (work()) return 1;
  for (int i = 0; i < 4; ++i) {
    swap(pt[i].first, pt[i].second);
    swap(px[i], py[i]);
  }
  bool f = work();
  for (int i = 0; i < 4; ++i) swap(pt[i].first, pt[i].second);
  if (f) {
    for (int i = 0; i < 4; ++i) {
      swap(ans[i].first, ans[i].second);
    }
    return 1;
  }
  return 0;
}
int main() {
  for (cin >> T; T; --T) {
    for (int i = 0; i < 4; ++i) cin >> pt[i].first >> pt[i].second;
    int L = 0, R = 1e9;
    while (L < R) {
      int mid = (L + R) >> 1;
      check(mid) ? R = mid : L = mid + 1;
    }
    if (L == 1e9)
      cout << -1 << endl;
    else {
      cout << L << endl;
      for (int i = 0; i < 4; ++i)
        cout << ans[i].first << ' ' << ans[i].second << endl;
    }
  }
  return 0;
}
