#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1.01e9;
const double eps = 1e-9;
const double pi = acos((double)-1.0);
const int mod = (int)1e9 + 7;
void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}
int mult(int x, int y) { return (long long)x * y % mod; }
vector<pair<int, int> > teste1;
const int MAGIC = 0;
long long ans;
pair<int, int> ent[4];
pair<long long, long long> res[4];
vector<pair<int, int> > prim(int aflnxcv, int adnxlnc, long long d) {
  vector<pair<int, int> > tes;
  int admxxc = aflnxcv + d, afdklxz = adnxlnc;
  int x2 = aflnxcv, y2 = adnxlnc + d;
  int x3 = aflnxcv + d, y3 = adnxlnc + d;
  tes.push_back(make_pair(aflnxcv, adnxlnc));
  tes.push_back(make_pair(admxxc, afdklxz));
  tes.push_back(make_pair(x2, y2));
  tes.push_back(make_pair(x3, y3));
  return tes;
}
vector<pair<int, int> > seg(int admxxc, int afdklxz, long long d) {
  vector<pair<int, int> > tes;
  int aflnxcv = admxxc - d, adnxlnc = afdklxz;
  int x2 = aflnxcv, y2 = adnxlnc + d;
  int x3 = aflnxcv + d, y3 = adnxlnc + d;
  tes.push_back(make_pair(aflnxcv, adnxlnc));
  tes.push_back(make_pair(admxxc, afdklxz));
  tes.push_back(make_pair(x2, y2));
  tes.push_back(make_pair(x3, y3));
  return tes;
}
vector<pair<int, int> > ter(int x2, int y2, long long d) {
  vector<pair<int, int> > tes;
  int aflnxcv = x2, adnxlnc = y2 - d;
  int admxxc = aflnxcv + d, afdklxz = adnxlnc;
  int x3 = aflnxcv + d, y3 = adnxlnc + d;
  tes.push_back(make_pair(aflnxcv, adnxlnc));
  tes.push_back(make_pair(admxxc, afdklxz));
  tes.push_back(make_pair(x2, y2));
  tes.push_back(make_pair(x3, y3));
  return tes;
}
vector<pair<int, int> > qua(int x3, int y3, long long d) {
  vector<pair<int, int> > tes;
  int aflnxcv = x3 - d, adnxlnc = y3 - d;
  int x2 = aflnxcv, y2 = adnxlnc + d;
  int admxxc = aflnxcv + d, afdklxz = adnxlnc;
  tes.push_back(make_pair(aflnxcv, adnxlnc));
  tes.push_back(make_pair(admxxc, afdklxz));
  tes.push_back(make_pair(x2, y2));
  tes.push_back(make_pair(x3, y3));
  return tes;
}
void vere(vector<pair<int, int> > tes) {
  vector<int> t;
  for (int i = 0; i < 4; i++) t.push_back(i);
  do {
    bool pode = true;
    int def = -1;
    vector<int> pd;
    for (int i = 0; i < 4; i++) {
      int v = t[i];
      if (ent[v].first != tes[i].first && ent[v].second != tes[i].second) {
        pode = false;
        break;
      }
      int ol = max(abs(ent[v].first - tes[i].first),
                   abs(ent[v].second - tes[i].second));
      pd.push_back(ol);
    }
    sort((pd).begin(), (pd).end());
    if (pode && ((int)(pd).size()) == 4) {
      if (ans > pd[3]) {
        ans = pd[3];
        for (int j = 0; j < 4; j++) {
          res[t[j]] = tes[j];
        }
      }
    }
  } while (next_permutation((t).begin(), (t).end()));
}
void conclui(int aflnxcv, int adnxlnc, long long d) {
  vere(prim(aflnxcv, adnxlnc, d));
  vere(seg(aflnxcv, adnxlnc, d));
  vere(ter(aflnxcv, adnxlnc, d));
  vere(qua(aflnxcv, adnxlnc, d));
}
void testa(long long dist) {
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      conclui(ent[i].first, ent[j].second, dist);
      conclui(ent[j].first, ent[i].second, dist);
    }
  }
}
int d;
long long calc(long long val, vector<int> po) {
  return max(max(abs(val - po[0]), abs(val - po[1] + d)),
             max(abs(val - po[2]), abs(val - po[3] + d)));
}
int ter(vector<int> po) {
  long long l = -1e12, r = 1e12;
  while (r - l > 5) {
    long long mid = (r + l) / 2;
    if (calc(mid, po) > calc(mid + 1, po))
      l = mid;
    else
      r = mid;
  }
  long long bst = 1e12, ans;
  for (int i = l; i <= r; i++) {
    if (calc(i, po) < bst) {
      bst = calc(i, po);
      ans = i;
    }
  }
  return ans;
}
void X(int i1, int i2, int j1, int j2) {
  if (ent[i1].first > ent[j1].first) {
    swap(i1, j1);
    swap(i2, j2);
  }
  d = ent[j1].first - ent[i1].first;
  vector<int> po;
  po.push_back(ent[i1].second);
  po.push_back(ent[i2].second);
  po.push_back(ent[j1].second);
  po.push_back(ent[j2].second);
  int meio = ter(po);
  int tot =
      max(max(abs(meio - ent[i1].second), abs(meio - ent[i2].second + d)),
          max(abs(meio - ent[j1].second), abs(meio - ent[j2].second + d)));
  if (tot < ans) {
    ans = tot;
    res[i1].first = ent[i1].first;
    res[i1].second = meio;
    res[i2].first = ent[i2].first;
    res[i2].second = meio + d;
    res[j1].first = ent[j1].first;
    res[j1].second = meio;
    res[j2].first = ent[j2].first;
    res[j2].second = meio + d;
  }
}
void Y(int i1, int i2, int j1, int j2) {
  if (ent[i1].second > ent[j2].second) {
    swap(i1, j1);
    swap(i2, j2);
  }
  d = ent[j1].second - ent[i1].second;
  vector<int> po;
  po.push_back(ent[i1].first);
  po.push_back(ent[i2].first);
  po.push_back(ent[j1].first);
  po.push_back(ent[j2].first);
  int meio = ter(po);
  int tot = max(max(abs(meio - ent[i1].first), abs(meio - ent[i2].first + d)),
                max(abs(meio - ent[j1].first), abs(meio - ent[j2].first + d)));
  if (tot < ans) {
    ans = tot;
    res[i1].first = meio;
    res[i1].second = ent[i1].second;
    res[i2].first = meio + d;
    res[i2].second = ent[i2].second;
    res[j1].first = meio;
    res[j1].second = ent[j1].second;
    res[j2].first = meio + d;
    res[j2].second = ent[j2].second;
  }
}
void solve() {
  teste1.push_back(make_pair(9, 57));
  teste1.push_back(make_pair(37, 57));
  teste1.push_back(make_pair(9, 85));
  teste1.push_back(make_pair(37, 85));
  ans = 1e13;
  for (int i = 0; i < 4; i++) {
    scanf("%d %d", &ent[i].first, &ent[i].second);
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < i; j++) {
      testa(abs(ent[i].first - ent[j].first));
      testa(abs(ent[i].second - ent[j].second));
    }
  }
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 4; j++)
      if (i != j) {
        for (int k = 0; k < 4; k++)
          if (i != k && j != k) {
            for (int l = 0; l < 4; l++)
              if (l != i && l != j && l != k) {
                if (ent[i].first == ent[j].first &&
                    ent[k].first == ent[l].first &&
                    ent[i].first != ent[k].first) {
                  X(i, j, k, l);
                }
                if (ent[i].second == ent[j].second &&
                    ent[k].second == ent[l].second &&
                    ent[i].second != ent[k].second) {
                  Y(i, j, k, l);
                }
              }
          }
      }
  }
  if (ans > 1e12)
    printf("-1\n");
  else {
    printf("%lld\n", ans);
    for (int i = 0; i < 4; ++i) {
      printf("%lld %lld\n", res[i].first - MAGIC, res[i].second - MAGIC);
    }
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}
