#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int MAXN = 1000006;
pair<int, int> P[4];
int best, x1, x2, d;
pair<int, int> ANS[4];
bool swapped;
int per[4];
int test(int y1, int y2) {
  assert(x2 - x1 == y2 - y1);
  pair<int, int> S[] = {pair<int, int>(x1, y1), pair<int, int>(x1, y2),
                        pair<int, int>(x2, y1), pair<int, int>(x2, y2)};
  for (int i = 0; i < (4); ++i) per[i] = i;
  int ret = 1 << 30;
  do {
    bool ok = 1;
    int c = 0;
    for (int i = 0; i < (4); ++i) {
      pair<int, int> w = P[per[i]];
      if (w.first != S[i].first && w.second != S[i].second) {
        ok = 0;
        continue;
      }
      c = max(c, abs(w.first - S[i].first) + abs(w.second - S[i].second));
    }
    if (ok && c < best) {
      best = c;
      for (int i = 0; i < (4); ++i) ANS[per[i]] = S[i];
      if (swapped)
        for (int i = 0; i < (4); ++i) swap(ANS[i].first, ANS[i].second);
    }
    if (ok) ret = min(ret, c);
  } while (next_permutation(per, per + 4));
  return ret;
}
int probuj(int second) {
  return min(test(second - d, second), test(second, second + d));
}
void go() {
  vector<int> first;
  for (int i = 0; i < (4); ++i) first.push_back(P[i].first);
  sort((first).begin(), (first).end());
  first.resize(unique((first).begin(), (first).end()) - first.begin());
  for (int i = 0; i < (first.size()); ++i)
    for (int j = 0; j < (i); ++j) {
      x1 = first[j], x2 = first[i];
      d = x2 - x1;
      for (int k = 0; k < (4); ++k) probuj(P[k].second);
      int zbior = 0;
      for (int k = 0; k < (4); ++k)
        if (P[k].first == x1)
          zbior += 1;
        else if (P[k].first == x2)
          zbior += 100;
      if (zbior != 202) continue;
      int kon = 200 * 1000 * 1000, pocz = -kon;
      while (pocz + 3 <= kon) {
        int w = (kon - pocz) / 3;
        int t1 = probuj(pocz + w), t2 = probuj(pocz + 2 * w);
        if (t1 >= t2)
          pocz = pocz + w;
        else
          kon = pocz + 2 * w;
      }
      int tutaj = 1 << 30;
      while (pocz <= kon) {
        tutaj = min(tutaj, probuj(pocz));
        ++pocz;
      }
    }
}
void solve() {
  for (int i = 0; i < (4); ++i) scanf("%d%d", &P[i].first, &P[i].second);
  best = 1 << 30;
  swapped = 0;
  go();
  swapped = 1;
  for (int i = 0; i < (4); ++i) swap(P[i].first, P[i].second);
  go();
  if (best == (1 << 30))
    puts("-1");
  else {
    printf("%d\n", best);
    for (int i = 0; i < (4); ++i)
      printf("%d %d\n", ANS[i].first, ANS[i].second);
  }
}
int main() {
  int te;
  scanf("%d", &te);
  while (te--) solve();
  return 0;
}
