#include <bits/stdc++.h>
using namespace std;
template <typename Tp>
inline void read(Tp &x) {
  static char c;
  static bool neg;
  x = 0, c = getchar(), neg = false;
  for (; !isdigit(c); c = getchar()) {
    if (c == '-') {
      neg = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (neg) {
    x = -x;
  }
}
const int INF = 0x3f3f3f3f;
const int N = 4;
const int dx[] = {0, 0, 1, 1};
const int dy[] = {0, 1, 1, 0};
inline void work() {
  static int x[N], y[N], p[N], dis[N], nx[N], ny[N];
  static int ansX[N], ansY[N];
  for (int i = 0; i < N; ++i) {
    read(x[i]), read(y[i]);
  }
  vector<int> vec;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      vec.emplace_back(std::abs(x[i] - x[j]));
      vec.emplace_back(std::abs(y[i] - y[j]));
    }
  }
  int ans = INF;
  for (const auto &d : vec) {
    vector<pair<int, int> > points;
    for (int i = 0; i < N; ++i) {
      for (int di = 0; di < 2; ++di) {
        for (int j = 0; j < N; ++j) {
          for (int dj = 0; dj < 2; ++dj) {
            points.emplace_back((pair<int, int>){x[i] - di * d, y[j] - dj * d});
          }
        }
      }
    }
    for (int i = 0; i < N; ++i) {
      p[i] = i;
    }
    do {
      for (int i = 0; i < N; ++i) {
        nx[i] = x[p[i]] - dx[i] * d;
        ny[i] = y[p[i]] - dy[i] * d;
      }
      auto px = minmax_element(nx, nx + N), py = minmax_element(ny, ny + N);
      if (*px.first == *px.second) {
        points.emplace_back(*px.first, (*py.first + *py.second) / 2);
      }
      if (*py.first == *py.second) {
        points.emplace_back((*px.first + *px.second) / 2, *py.first);
      }
    } while (next_permutation(p, p + N));
    for (const auto &pir : points) {
      int tx = pir.first, ty = pir.second;
      for (int i = 0; i < N; ++i) {
        p[i] = i;
      }
      do {
        bool valid = true;
        for (int i = 0, x0, y0, x1, y1; i < N; ++i) {
          x0 = tx + dx[i] * d, y0 = ty + dy[i] * d;
          x1 = x[p[i]], y1 = y[p[i]];
          if (x0 == x1) {
            dis[i] = std::abs(y0 - y1);
          } else if (y0 == y1) {
            dis[i] = std::abs(x0 - x1);
          } else {
            valid = false;
            break;
          }
        }
        if (valid) {
          int res = *max_element(dis, dis + N);
          if (ans > res) {
            ans = res;
            for (int i = 0; i < N; ++i) {
              ansX[p[i]] = tx + dx[i] * d;
              ansY[p[i]] = ty + dy[i] * d;
            }
          }
        }
      } while (next_permutation(p, p + N));
    }
  }
  if (ans == INF) {
    puts("-1");
  } else {
    printf("%d\n", ans);
    for (int i = 0; i < N; ++i) {
      printf("%d %d\n", ansX[i], ansY[i]);
    }
  }
}
int T;
int main() {
  read(T);
  for (int cas = 0; cas < T; ++cas) {
    work();
  }
}
