#include <bits/stdc++.h>
using namespace std;
int tc;
int v[4], x[4], y[4], ax[4], ay[4], ans, tx[4], ty[4];
set<int> sv, sh;
vector<int> p;
void test() {
  sort((p).begin(), (p).end());
  do {
    bool can = 1;
    int ret = 0;
    for (int i = 0; i < 4; i++) {
      if (x[i] != tx[p[i]] && y[i] != ty[p[i]]) {
        can = 0;
        break;
      } else
        ret = max(ret, abs(x[i] - tx[p[i]]) + abs(y[i] - ty[p[i]]));
    }
    if (!can) continue;
    if (ret < ans) {
      ans = ret;
      for (int i = 0; i < 4; i++) ax[i] = tx[p[i]], ay[i] = ty[p[i]];
    }
  } while (next_permutation((p).begin(), (p).end()));
}
int main() {
  scanf("%d", &tc);
  for (int i = 0; i < 4; i++) p.push_back(i);
  while (tc--) {
    ans = 1000000000;
    for (int i = 0; i < 4; i++) scanf("%d%d", &x[i], &y[i]);
    for (int b = 0; b < (1 << 4); b++) {
      for (int i = 0; i < 4; i++) {
        v[i] = !!(b & (1 << i));
      }
      sv.clear(), sh.clear();
      for (int i = 0; i < 4; i++) {
        if (v[i])
          sv.insert(x[i]);
        else
          sh.insert(y[i]);
      }
      if ((int)(sv).size() >= 3 || (int)(sh).size() >= 3) continue;
      if ((int)(sv).size() == 2 && (int)(sh).size() == 2) {
        if ((*sv.rbegin() - *sv.begin()) != (*sh.rbegin() - *sh.begin()))
          continue;
        tx[0] = tx[1] = *sv.begin();
        tx[2] = tx[3] = *sv.rbegin();
        ty[0] = ty[3] = *sh.begin();
        ty[1] = ty[2] = *sh.rbegin();
        test();
      } else if ((int)(sv).size() == 2 && (int)(sh).size() == 1) {
        int l = *sv.rbegin() - *sv.begin();
        tx[0] = tx[1] = *sv.begin();
        tx[2] = tx[3] = *sv.rbegin();
        ty[0] = ty[3] = *sh.begin() - l;
        ty[1] = ty[2] = *sh.begin();
        test();
        tx[0] = tx[1] = *sv.begin();
        tx[2] = tx[3] = *sv.rbegin();
        ty[0] = ty[3] = *sh.begin();
        ty[1] = ty[2] = *sh.begin() + l;
        test();
      } else if ((int)(sh).size() == 2 && (int)(sv).size() == 1) {
        int l = *sh.rbegin() - *sh.begin();
        tx[0] = tx[1] = *sv.begin();
        tx[2] = tx[3] = *sv.begin() + l;
        ty[0] = ty[3] = *sh.begin();
        ty[1] = ty[2] = *sh.rbegin();
        test();
        tx[0] = tx[1] = *sv.begin() - l;
        tx[2] = tx[3] = *sv.begin();
        ty[0] = ty[3] = *sh.begin();
        ty[1] = ty[2] = *sh.rbegin();
        test();
      } else if ((int)(sv).size() == 2 && (int)(sh).size() == 0) {
        int w = *sv.rbegin() - *sv.begin();
        vector<int> l, r;
        for (int i = 0; i < 4; i++) {
          if (x[i] == *sv.begin())
            l.push_back(i);
          else {
            assert(x[i] == *sv.rbegin());
            r.push_back(i);
          }
        }
        if ((int)(l).size() != 2 || (int)(r).size() != 2) continue;
        if (y[l[0]] > y[l[1]]) swap(l[0], l[1]);
        if (y[r[0]] > y[r[1]]) swap(r[0], r[1]);
        int b = 0, e = 1000000000, a = 1000000000;
        while (b < e + 1) {
          int m = (b + e) / 2;
          int e1 = min(y[l[0]] + m, y[r[0]] + m);
          int b1 = max(y[l[0]] - m, y[r[0]] - m);
          int e2 = min(y[l[1]] + m, y[r[1]] + m);
          int b2 = max(y[l[1]] - m, y[r[1]] - m);
          if (b1 > e1 || b2 > e2) {
            b = m + 1;
          } else if (b2 - e1 <= w && w <= e2 - b1) {
            a = min(a, m);
            e = m - 1;
          } else
            b = m + 1;
        }
        int e1 = min(y[l[0]] + a, y[r[0]] + a);
        int b1 = max(y[l[0]] - a, y[r[0]] - a);
        int e2 = min(y[l[1]] + a, y[r[1]] + a);
        int b2 = max(y[l[1]] - a, y[r[1]] - a);
        int h = e2;
        if (h - w > e1) h -= (h - w - e1);
        tx[0] = tx[1] = *sv.begin();
        tx[2] = tx[3] = *sv.rbegin();
        ty[0] = ty[3] = h - w;
        ty[1] = ty[2] = h;
        test();
      } else if ((int)(sh).size() == 2 && (int)(sv).size() == 0) {
        int w = *sh.rbegin() - *sh.begin();
        vector<int> l, r;
        for (int i = 0; i < 4; i++) {
          if (y[i] == *sh.begin())
            l.push_back(i);
          else {
            assert(y[i] == *sh.rbegin());
            r.push_back(i);
          }
        }
        if ((int)(l).size() != 2 || (int)(r).size() != 2) continue;
        if (x[l[0]] > x[l[1]]) swap(l[0], l[1]);
        if (x[r[0]] > x[r[1]]) swap(r[0], r[1]);
        int b = 0, e = 1000000000, a = 1000000000;
        while (b < e + 1) {
          int m = (b + e) / 2;
          int e1 = min(x[l[0]] + m, x[r[0]] + m);
          int b1 = max(x[l[0]] - m, x[r[0]] - m);
          int e2 = min(x[l[1]] + m, x[r[1]] + m);
          int b2 = max(x[l[1]] - m, x[r[1]] - m);
          if (b1 > e1 || b2 > e2) {
            b = m + 1;
          } else if (b2 - e1 <= w && w <= e2 - b1) {
            a = min(a, m);
            e = m - 1;
          } else
            b = m + 1;
        }
        int e1 = min(x[l[0]] + a, x[r[0]] + a);
        int b1 = max(x[l[0]] - a, x[r[0]] - a);
        int e2 = min(x[l[1]] + a, x[r[1]] + a);
        int b2 = max(x[l[1]] - a, x[r[1]] - a);
        int h = e2;
        if (h - w > e1) h -= (h - w - e1);
        tx[0] = tx[1] = h - w;
        tx[2] = tx[3] = h;
        ty[0] = ty[3] = *sh.begin();
        ty[1] = ty[2] = *sh.rbegin();
        test();
      }
    }
    if (ans == 1000000000)
      printf("-1\n");
    else {
      printf("%d\n", ans);
      for (int i = 0; i < 4; i++) printf("%d %d\n", ax[i], ay[i]);
    }
  }
}
