#include <bits/stdc++.h>
using namespace std;
const int INF = 5e8;
struct Point {
  int x, y;
  Point() {}
  Point(int x, int y) : x(x), y(y) {}
};
void update_ans(Point poi[4], int x0, int x1, int y0, int y1, int &ans,
                Point poi_ans[4]) {
  Point target[4] = {Point(x0, y0), Point(x0, y1), Point(x1, y0),
                     Point(x1, y1)};
  int corr[4] = {0, 1, 2, 3};
  do {
    Point match[4];
    for (int i = 0; i < 4; i++) match[i] = target[corr[i]];
    bool flag = true;
    int curr = 0;
    for (int i = 0; i < 4; i++) {
      if (poi[i].x != match[i].x && poi[i].y != match[i].y) {
        flag = false;
        break;
      }
      curr = max(curr, abs(poi[i].x - match[i].x) + abs(poi[i].y - match[i].y));
    }
    if (flag && (ans == -1 || ans > curr)) {
      ans = curr;
      for (int i = 0; i < 4; i++) poi_ans[i] = match[i];
    }
  } while (next_permutation(corr, corr + 4));
}
void solve() {
  Point poi[4], poi_ans[4];
  for (int i = 0; i < 4; i++) {
    scanf("%d%d", &poi[i].x, &poi[i].y);
  }
  int ans = -1;
  for (int mask = 0; mask < 1 << 4; mask++) {
    vector<int> vx, vy;
    for (int i = 0; i < 4; i++) {
      if (mask >> i & 1)
        vx.push_back(poi[i].x);
      else
        vy.push_back(poi[i].y);
    }
    sort(vx.begin(), vx.end());
    vx.erase(unique(vx.begin(), vx.end()), vx.end());
    sort(vy.begin(), vy.end());
    vy.erase(unique(vy.begin(), vy.end()), vy.end());
    if (vx.size() == 0) {
      if (vy.size() != 2) continue;
      vector<int> vx_y0, vx_y1;
      for (int i = 0; i < 4; i++) {
        if (poi[i].y == vy[0])
          vx_y0.push_back(poi[i].x);
        else
          vx_y1.push_back(poi[i].x);
      }
      if (vx_y0.size() != 2) continue;
      sort(vx_y0.begin(), vx_y0.end());
      sort(vx_y1.begin(), vx_y1.end());
      int l = -INF, r = INF, d = vy[1] - vy[0];
      while (l != r) {
        int x = (r - l) / 3;
        int m1 = l + x, m2 = r - x;
        const auto cost = [&](int a) {
          int res = 0;
          res = max(res, abs(vx_y0[0] - a));
          res = max(res, abs(vx_y0[1] - (a + d)));
          res = max(res, abs(vx_y1[0] - a));
          res = max(res, abs(vx_y1[1] - (a + d)));
          return res;
        };
        if (cost(m1) <= cost(m2))
          r = m2 - 1;
        else
          l = m1 + 1;
      }
      update_ans(poi, l, l + d, vy[0], vy[1], ans, poi_ans);
    } else if (vy.size() == 0) {
      if (vx.size() != 2) continue;
      vector<int> vy_x0, vy_x1;
      for (int i = 0; i < 4; i++) {
        if (poi[i].x == vx[0])
          vy_x0.push_back(poi[i].y);
        else
          vy_x1.push_back(poi[i].y);
      }
      if (vy_x0.size() != 2) continue;
      sort(vy_x0.begin(), vy_x0.end());
      sort(vy_x1.begin(), vy_x1.end());
      int l = -INF, r = INF, d = vx[1] - vx[0];
      while (l != r) {
        int x = (r - l) / 3;
        int m1 = l + x, m2 = r - x;
        const auto cost = [&](int a) {
          int res = 0;
          res = max(res, abs(vy_x0[0] - a));
          res = max(res, abs(vy_x0[1] - (a + d)));
          res = max(res, abs(vy_x1[0] - a));
          res = max(res, abs(vy_x1[1] - (a + d)));
          return res;
        };
        if (cost(m1) <= cost(m2))
          r = m2 - 1;
        else
          l = m1 + 1;
      }
      update_ans(poi, vx[0], vx[1], l, l + d, ans, poi_ans);
    } else if (vx.size() == 1 && vy.size() == 2) {
      int d = vy[1] - vy[0];
      update_ans(poi, vx[0] - d, vx[0], vy[0], vy[1], ans, poi_ans);
      update_ans(poi, vx[0], vx[0] + d, vy[0], vy[1], ans, poi_ans);
    } else if (vx.size() == 2 && vy.size() == 1) {
      int d = vx[1] - vx[0];
      update_ans(poi, vx[0], vx[1], vy[0] - d, vy[0], ans, poi_ans);
      update_ans(poi, vx[0], vx[1], vy[0], vy[0] + d, ans, poi_ans);
    } else if (vx.size() == 2 && vy.size() == 2) {
      if (vx[1] - vx[0] == vy[1] - vy[0]) {
        update_ans(poi, vx[0], vx[1], vy[0], vy[1], ans, poi_ans);
      }
    }
  }
  printf("%d\n", ans);
  if (ans != -1) {
    for (int i = 0; i < 4; i++) printf("%d %d\n", poi_ans[i].x, poi_ans[i].y);
  }
}
int main() {
  int T;
  scanf("%d", &T);
  for (int i = 1; i <= T; i++) {
    solve();
  }
}
