#include <bits/stdc++.h>
using namespace std;
int ord[4];
pair<int, int> pos[4];
pair<int, int> g;
int solve(int hmask, int d) {
  pair<int, int> target[4];
  for (int i = 0; i < 4; i++) target[i] = pos[ord[i]];
  if (hmask == 0 || hmask == 15) {
    target[1].second -= d;
    target[2].first -= d;
    target[2].second -= d;
    target[3].first -= d;
    if (hmask == 0) {
      for (int i = 0; i < 3; i++)
        if (target[i].first != target[i + 1].first) return -1;
      int hi = -0x7fFFffFF, lo = 0x7fFFffFF;
      for (int i = 0; i < 4; i++)
        hi = max(hi, target[i].second), lo = min(lo, target[i].second);
      int ret = (hi - lo + 1) / 2;
      g = pair<int, int>(target[0].first, lo + ret);
      return ret;
    } else {
      for (int i = 0; i < 3; i++)
        if (target[i].second != target[i + 1].second) return -1;
      int hi = -0x7fFFffFF, lo = 0x7fFFffFF;
      for (int i = 0; i < 4; i++)
        hi = max(hi, target[i].first), lo = min(lo, target[i].first);
      int ret = (hi - lo + 1) / 2;
      g = pair<int, int>(lo + ret, target[0].second);
      return ret;
    }
  }
  int h = -1, v = -1;
  for (int i = 0; i < 4; i++)
    if (hmask & (1 << i))
      h = i;
    else
      v = i;
  pair<int, int> coin(pos[ord[v]].first, pos[ord[h]].second);
  int ret = 0x7fFFffFF;
  pair<int, int> off[4] = {{0, 0}, {0, -d}, {-d, -d}, {-d, 0}};
  for (int i = 0; i < 4; i++) {
    pair<int, int> v0(coin.first + off[i].first, coin.second + off[i].second);
    pair<int, int> goal[4] = {v0, v0, v0, v0};
    goal[1].second += d;
    goal[2].first += d;
    goal[2].second += d;
    goal[3].first += d;
    int here = 0;
    for (int j = 0; j < 4; j++) {
      if (hmask & (1 << j)) {
        if (goal[j].second != target[j].second) {
          here = -1;
          break;
        }
        here = max(here, abs(goal[j].first - target[j].first));
      } else {
        if (goal[j].first != target[j].first) {
          here = -1;
          break;
        }
        here = max(here, abs(goal[j].second - target[j].second));
      }
    }
    if (here >= 0 && here < ret) {
      ret = here;
      g = pair<int, int>(coin.first + off[i].first,
                         coin.second + off[i].second);
      return ret;
    }
  }
  if (ret < 0x7fFFffFF)
    return ret;
  else
    return -1;
}
int main() {
  cin.sync_with_stdio(0), cout.sync_with_stdio(0);
  int T;
  cin >> T;
  while (T--) {
    for (int i = 0; i < 4; i++) cin >> pos[i].first >> pos[i].second;
    for (int i = 0; i < 4; i++) ord[i] = i;
    int ans = -1;
    pair<int, int> c;
    int dd;
    int o[4];
    do {
      for (int i = 0; i < 16; i++) {
        vector<int> ds;
        for (int j = 0; j < 4; j++) {
          for (int k = j + 1; k < 4; k++) {
            bool h1 = !!(i & (1 << j));
            bool h2 = !!(i & (1 << k));
            if (h1 && h2) {
              ds.push_back(abs(pos[ord[j]].second - pos[ord[k]].second));
            } else if ((!h1) && (!h2)) {
              ds.push_back(abs(pos[ord[j]].first - pos[ord[k]].first));
            }
          }
        }
        sort(ds.begin(), ds.end());
        ds.erase(unique(ds.begin(), ds.end()), ds.end());
        for (int d : ds) {
          if (d == 0) continue;
          int now = solve(i, d);
          if (now >= 0) {
            if (ans < 0 || ans > now) {
              ans = now;
              c = g;
              dd = d;
              memcpy(o, ord, sizeof(o));
            }
          }
        }
      }
    } while (next_permutation(ord, ord + 4));
    cout << ans << endl;
    if (ans >= 0) {
      pair<int, int> p[4] = {c, c, c, c};
      p[o[1]].second += dd;
      p[o[2]].first += dd;
      p[o[2]].second += dd;
      p[o[3]].first += dd;
      for (int i = 0; i < 4; i++)
        cout << p[i].first << ' ' << p[i].second << endl;
    }
  }
}
