#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream &operator<<(ostream &s, const pair<A, B> &p) {
  return s << "(" << p.first << "," << p.second << ")";
}
template <typename T>
ostream &operator<<(ostream &s, const vector<T> &c) {
  s << "[ ";
  for (auto it : c) s << it << " ";
  s << "]";
  return s;
}
const long long INF = 1LL << 30;
pair<long long, long long> pt[4];
pair<long long, long long> ans[4];
int perm[24][4];
bool check(long long x, long long y, long long dx, long long dy,
           long long thr) {
  pair<long long, long long> tar[4];
  tar[0] = {x, y};
  tar[1] = {x, y + dy};
  tar[2] = {x + dx, y};
  tar[3] = {x + dx, y + dy};
  for (int p = 0; p < 24; p++) {
    bool ok = true;
    for (int i = 0; i < 4; i++) {
      pair<long long, long long> p1 = pt[i], p2 = tar[perm[p][i]];
      if (abs(p1.first - p2.first) + abs(p1.second - p2.second) > thr) {
        ok = false;
        break;
      }
      if (p1.first != p2.first and p1.second != p2.second) {
        ok = false;
        break;
      }
    }
    if (ok) {
      for (int i = 0; i < 4; i++) ans[i] = tar[perm[p][i]];
      return true;
    }
  }
  return false;
}
bool test(long long thr) {
  vector<long long> vx, vy;
  for (int i = 0; i < 4; i++) {
    vx.push_back(pt[i].first);
    vx.push_back(pt[i].first - thr);
    vx.push_back(pt[i].first + thr);
    vy.push_back(pt[i].second);
    vy.push_back(pt[i].second - thr);
    vy.push_back(pt[i].second + thr);
  }
  sort(begin(vx), end(vx));
  vx.resize(unique(begin(vx), end(vx)) - vx.begin());
  sort(begin(vy), end(vy));
  vy.resize(unique(begin(vy), end(vy)) - vy.begin());
  for (long long x : vx) {
    for (long long y : vy) {
      for (long long y2 : vy) {
        long long dy = y2 - y;
        if (dy <= 0) continue;
        if (check(x, y, dy, dy, thr)) return true;
        if (check(x, y, -dy, dy, thr)) return true;
      }
      for (long long x2 : vx) {
        long long dx = x2 - x;
        if (dx <= 0) continue;
        if (check(x, y, dx, dx, thr)) return true;
        if (check(x, y, dx, -dx, thr)) return true;
      }
    }
  }
  return false;
}
void solve() {
  for (int i = 0; i < 4; i++) perm[0][i] = i;
  for (int i = 1; i < 24; i++) {
    for (int j = 0; j < 4; j++) perm[i][j] = perm[i - 1][j];
    next_permutation(perm[i], perm[i] + 4);
  }
  long long lb = 0, rb = INF;
  while (lb < rb) {
    long long mb = (lb + rb) / 2;
    if (test(mb))
      rb = mb;
    else
      lb = mb + 1;
  }
  if (lb == INF)
    cout << -1 << endl;
  else {
    test(lb);
    cout << lb << endl;
    for (int i = 0; i < 4; i++)
      cout << ans[i].first << " " << ans[i].second << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    for (int i = 0; i < 4; i++) cin >> pt[i].first >> pt[i].second;
    solve();
  }
  return 0;
}
