#include <bits/stdc++.h>
const int INF = 1e9;
int X[4], Y[4], ansX[4], ansY[4], perm[4], cX[4], cY[4], ans;
const int dx[4] = {-1, -1, 0, 0};
const int dy[4] = {-1, 0, -1, 0};
int read() {
  char c = getchar();
  int ans = 0;
  bool flag = true;
  while (!isdigit(c)) flag &= (c != '-'), c = getchar();
  while (isdigit(c)) ans = 10 * ans + c - '0', c = getchar();
  return flag ? ans : -ans;
}
void Write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x < 10)
    putchar(x + '0');
  else
    Write(x / 10), putchar(x % 10 + '0');
}
int min(int x, int y) { return x < y ? x : y; }
int max(int x, int y) { return x > y ? x : y; }
void _min(int &x, int y) {
  if (x > y) x = y;
}
void _max(int &x, int y) {
  if (x < y) x = y;
}
void update(int d) {
  if (ans > d) {
    ans = d;
    for (int i = 0; i < 4; i++) ansX[perm[i]] = cX[i], ansY[perm[i]] = cY[i];
  }
}
void solve() {
  int L, d;
  if (X[0] == X[1] && X[2] == X[3] && X[2] > X[0]) {
    std::vector<int> vec(4);
    L = X[2] - X[0];
    vec[0] = Y[0], vec[1] = Y[1] - L;
    vec[2] = Y[2], vec[3] = Y[3] - L;
    std::sort(vec.begin(), vec.end());
    d = (vec.back() - vec.front() + 1) / 2;
    cY[0] = cY[2] = vec.front() + d;
    cY[1] = cY[3] = vec.front() + d + L;
    std::copy(X, X + 4, cX);
    update(d);
  }
  if (Y[0] == Y[2] && Y[1] == Y[3] && Y[1] > Y[0]) {
    std::vector<int> vec(4);
    L = Y[1] - Y[0];
    vec[0] = X[0], vec[2] = X[2] - L;
    vec[1] = X[1], vec[3] = X[3] - L;
    std::sort(vec.begin(), vec.end());
    d = (vec.back() - vec.front() + 1) / 2;
    cX[0] = cX[1] = vec.front() + d;
    cX[2] = cX[3] = vec.front() + d + L;
    std::copy(Y, Y + 4, cY);
    update(d);
  }
  std::vector<int> Ls;
  Ls.reserve(12);
  for (int i = 0; i < 4; i++)
    for (int j = i + 1; j < 4; j++) {
      if (X[i] != X[j]) Ls.push_back(abs(X[i] - X[j]));
      if (Y[i] != Y[j]) Ls.push_back(abs(Y[i] - Y[j]));
    }
  std::sort(Ls.begin(), Ls.end());
  Ls.resize(std::unique(Ls.begin(), Ls.end()) - Ls.begin());
  std::vector<std::pair<int, int> > Ps;
  Ps.reserve(12);
  for (int i = 0; i < 4; i++)
    for (int j = i + 1; j < 4; j++)
      Ps.emplace_back(X[i], Y[j]), Ps.emplace_back(X[j], Y[i]);
  for (auto i : Ls)
    for (auto j : Ps)
      for (int k = 0; k < 4; k++) {
        cX[0] = j.first + dx[k] * i, cX[1] = cX[0], cX[2] = cX[3] = cX[0] + i;
        cY[0] = j.second + dy[k] * i, cY[2] = cY[0], cY[1] = cY[3] = cY[0] + i;
        int d = 0;
        for (int t = 0; t < 4; t++) {
          if (cX[t] != X[t] && cY[t] != Y[t]) goto stop;
          _max(d, abs(cX[t] - X[t]) + abs(cY[t] - Y[t]));
        }
        update(d);
      stop:;
      }
}
int main() {
  int t = read();
  while (t--) {
    for (int i = 0; i < 4; i++) X[i] = read(), Y[i] = read();
    ans = INF;
    std::iota(perm, perm + 4, 0);
    do {
      static int tX[4], tY[4];
      for (int i = 0; i < 4; i++) tX[i] = X[i], tY[i] = Y[i];
      for (int i = 0; i < 4; i++) X[i] = tX[perm[i]], Y[i] = tY[perm[i]];
      solve();
      for (int i = 0; i < 4; i++) X[i] = tX[i], Y[i] = tY[i];
    } while (std::next_permutation(perm, perm + 4));
    if (ans == INF)
      puts("-1");
    else {
      Write(ans), putchar('\n');
      for (int i = 0; i < 4; i++)
        assert(ansX[i] == X[i] || ansY[i] == Y[i]),
            assert(abs(ansX[i] - X[i]) + abs(ansY[i] - Y[i]) <= ans);
      for (int i = 0; i < 4; i++)
        Write(ansX[i]), putchar(' '), Write(ansY[i]), putchar('\n');
    }
  }
  return 0;
}
