#include <bits/stdc++.h>
using namespace std;
const int INF = 5e8;
int x[5], y[5];
int ans;
vector<pair<int, int> > tr;
void minimize(int &a, int b) { a = min(a, b); }
void maximize(int &a, int b) { a = max(a, b); }
int dist(int x1, int y1, int x2, int y2) {
  if (x1 == x2) return abs(y1 - y2);
  if (y1 == y2) return abs(x1 - x2);
  return INF;
}
int query(int x1, int x2, int y1, int y2, int id) {
  vector<pair<int, int> > vi;
  vi.push_back({x1, y1});
  vi.push_back({x1, y2});
  vi.push_back({x2, y1});
  vi.push_back({x2, y2});
  vector<int> p;
  int rz = INF;
  for (int i = 0; i < 4; ++i) p.push_back(i);
  do {
    int sumD = 0;
    for (int i = 0; i < 4; ++i)
      maximize(sumD, dist(x[i], y[i], vi[p[i]].first, vi[p[i]].second));
    minimize(rz, sumD);
    if (ans > sumD) {
      ans = sumD;
      tr.clear();
      for (int i = 0; i < 4; ++i)
        if (!id)
          tr.push_back(vi[p[i]]);
        else {
          auto ss = vi[p[i]];
          swap(ss.first, ss.second);
          ss.second = -ss.second;
          tr.push_back(ss);
        }
    }
  } while (next_permutation(p.begin(), p.end()));
  return rz;
}
int get_ans(int id) {
  int rz = INF;
  vector<int> xx, yy;
  for (int i = 0; i < 4; ++i) xx.push_back(x[i]), yy.push_back(y[i]);
  for (auto x1 : xx)
    for (auto x2 : xx)
      if (x1 < x2) {
        for (auto y1 : yy) {
          minimize(rz, query(x1, x2, y1, y1 + abs(x1 - x2), id));
          minimize(rz, query(x1, x2, y1, y1 - abs(x1 - x2), id));
        }
      }
  for (auto x1 : xx)
    for (auto x2 : xx)
      if (x1 < x2) {
        int lo = -INF, hi = INF;
        while (hi - lo > 4) {
          int m1 = lo + hi >> 1;
          int m2 = m1 + 1;
          if (query(x1, x2, m1, m1 + abs(x1 - x2), id) >
              query(x1, x2, m2, m2 + abs(x1 - x2), id))
            lo = m1;
          else
            hi = m2;
        }
        for (int i = lo; i <= hi; ++i)
          minimize(rz, query(x1, x2, i, i + abs(x1 - x2), id));
      }
  return rz;
}
int main() {
  ios::sync_with_stdio(0);
  int T;
  cin >> T;
  for (; T; T--) {
    for (int i = 0; i < 4; ++i) cin >> x[i] >> y[i];
    ans = INF;
    tr.clear();
    minimize(ans, get_ans(0));
    for (int i = 0; i < 4; ++i) swap(x[i], y[i]), x[i] = -x[i];
    minimize(ans, get_ans(1));
    if (ans == INF)
      cout << "-1 \n";
    else {
      cout << ans << '\n';
      for (auto ss : tr) cout << ss.first << ' ' << ss.second << '\n';
    }
  }
}
