#include <bits/stdc++.h>
using namespace std;
template <class X, class Y>
void minimize(X &x, const Y &y) {
  if (x > y) x = y;
}
template <class X, class Y>
void maximize(X &x, const Y &y) {
  if (x < y) x = y;
}
const int INF = (int)1e9 + 7;
const pair<int, int> dir[] = {pair<int, int>(0, 1), pair<int, int>(1, 0),
                              pair<int, int>(0, -1), pair<int, int>(-1, 0)};
int canMove(const pair<int, int> &sta, const pair<int, int> &dir,
            const pair<int, int> &fin) {
  if (dir.first == 0 && sta.first != fin.first) return (INF);
  if (dir.second == 0 && sta.second != fin.second) return (INF);
  if (dir.first != 0)
    return ((fin.first - sta.first) * dir.first < 0
                ? INF
                : (fin.first - sta.first) / dir.first);
  if (dir.second != 0)
    return ((fin.second - sta.second) * dir.second < 0
                ? INF
                : (fin.second - sta.second) / dir.second);
  assert(false);
}
int intersect(int x, const vector<int> &pos, const vector<int> &sign) {
  vector<pair<int, int> > range;
  for (int i = 0, _n = (4); i < _n; i = i + 1)
    range.push_back(make_pair(pos[i], pos[i] + x * sign[i]));
  for (int i = 0, _n = (4); i < _n; i = i + 1)
    if (range[i].first > range[i].second) swap(range[i].first, range[i].second);
  int L = range[0].first;
  int R = range[0].second;
  for (__typeof((range).begin()) it = (range).begin(); it != (range).end();
       it++) {
    maximize(L, it->first);
    minimize(R, it->second);
  }
  return (L > R ? INF : R);
}
int unfixCase(const vector<int> &pos, const vector<int> &sign) {
  int L = 0;
  int R = INF;
  while (true) {
    if (L == R) return (L);
    if (R - L == 1) return (intersect(L, pos, sign) < INF ? L : R);
    int M = (L + R) >> 1;
    if (intersect(M, pos, sign) < INF)
      R = M;
    else
      L = M + 1;
  }
}
pair<int, vector<pair<int, int> > > solve(const vector<pair<int, int> > &point,
                                          const vector<pair<int, int> > &dir,
                                          const vector<int> &order) {
  int x = INF, y = INF, t = INF, xt = INF, yt = INF;
  for (int i = 0, _n = (4); i < _n; i = i + 1)
    if (order[i] % 2 == 0 && dir[i].first == 0) x = point[i].first;
  for (int i = 0, _n = (4); i < _n; i = i + 1)
    if (order[i] < 2 && dir[i].second == 0) y = point[i].second;
  for (int i = 0, _n = (4); i < _n; i = i + 1)
    if (order[i] % 2 != 0 && dir[i].first == 0) xt = point[i].first;
  for (int i = 0, _n = (4); i < _n; i = i + 1)
    if (order[i] >= 2 && dir[i].second == 0) yt = point[i].second;
  if (x < INF && xt < INF) t = xt - x;
  if (y < INF && yt < INF) t = yt - y;
  if (t < INF && xt < INF) x = xt - t;
  if (t < INF && yt < INF) y = yt - t;
  assert(x < INF || y < INF);
  assert(t < INF);
  if (x < INF && y < INF) {
    vector<pair<int, int> > fin;
    for (int i = 0, _n = (4); i < _n; i = i + 1) {
      if (order[i] == 0) fin.push_back(pair<int, int>(x, y));
      if (order[i] == 1) fin.push_back(pair<int, int>(x + t, y));
      if (order[i] == 2) fin.push_back(pair<int, int>(x, y + t));
      if (order[i] == 3) fin.push_back(pair<int, int>(x + t, y + t));
    }
    int res = 0;
    for (int i = 0, _n = (4); i < _n; i = i + 1)
      maximize(res, canMove(point[i], dir[i], fin[i]));
    return (make_pair(res, fin));
  }
  vector<int> pos, sign;
  for (int i = 0, _n = (4); i < _n; i = i + 1)
    sign.push_back(x >= INF ? dir[i].first : dir[i].second);
  for (int i = 0, _n = (4); i < _n; i = i + 1) {
    if (x >= INF)
      pos.push_back(order[i] % 2 == 0 ? point[i].first : point[i].first - t);
    else
      pos.push_back(order[i] < 2 ? point[i].second : point[i].second - t);
  }
  int res = unfixCase(pos, sign);
  int val = intersect(res, pos, sign);
  vector<pair<int, int> > fin;
  for (int i = 0, _n = (4); i < _n; i = i + 1) {
    if (x >= INF)
      fin.push_back(order[i] % 2 == 0
                        ? pair<int, int>(val, point[i].second)
                        : pair<int, int>(val + t, point[i].second));
    else
      fin.push_back(order[i] < 2 ? pair<int, int>(point[i].first, val)
                                 : pair<int, int>(point[i].first, val + t));
  }
  return (make_pair(res, fin));
}
bool checkSolution(const vector<pair<int, int> > &sta,
                   const vector<pair<int, int> > &dir,
                   const vector<pair<int, int> > &fin, const vector<int> &order,
                   int time) {
  if (time >= INF) return (false);
  for (int i = 0, _n = (4); i < _n; i = i + 1)
    if (canMove(sta[i], dir[i], fin[i]) > time) return (false);
  int x, y, t;
  for (int i = 0, _n = (4); i < _n; i = i + 1)
    if (order[i] == 0) {
      x = fin[i].first;
      y = fin[i].second;
    }
  for (int i = 0, _n = (4); i < _n; i = i + 1)
    if (order[i] == 1) t = fin[i].first - x;
  if (t == 0) return (false);
  for (int i = 0, _n = (4); i < _n; i = i + 1) {
    if (order[i] == 0 && (fin[i].first != x || fin[i].second != y))
      return (false);
    if (order[i] == 1 && (fin[i].first != x + t || fin[i].second != y))
      return (false);
    if (order[i] == 2 && (fin[i].first != x || fin[i].second != y + t))
      return (false);
    if (order[i] == 3 && (fin[i].first != x + t || fin[i].second != y + t))
      return (false);
  }
  return (true);
}
void process(void) {
  vector<pair<int, int> > point;
  for (int i = 0, _n = (4); i < _n; i = i + 1) {
    int x, y;
    scanf("%d%d", &x, &y);
    point.push_back(make_pair(x, y));
  }
  vector<int> order;
  for (int i = 0, _n = (4); i < _n; i = i + 1) order.push_back(i);
  pair<int, vector<pair<int, int> > > best(INF, vector<pair<int, int> >());
  do {
    for (int i = 0, _n = (4); i < _n; i = i + 1)
      for (int j = 0, _n = (4); j < _n; j = j + 1)
        for (int k = 0, _n = (4); k < _n; k = k + 1)
          for (int l = 0, _n = (4); l < _n; l = l + 1) {
            vector<pair<int, int> > curDir;
            curDir.push_back(dir[i]);
            curDir.push_back(dir[j]);
            curDir.push_back(dir[k]);
            curDir.push_back(dir[l]);
            pair<int, vector<pair<int, int> > > sol =
                solve(point, curDir, order);
            if (checkSolution(point, curDir, sol.second, order, sol.first)) {
              minimize(best, sol);
            }
          }
  } while (next_permutation((order).begin(), (order).end()));
  if (best.first >= INF)
    printf("-1\n");
  else {
    printf("%d\n", best.first);
    for (__typeof((best.second).begin()) it = (best.second).begin();
         it != (best.second).end(); it++)
      printf("%d %d\n", it->first, it->second);
  }
}
int main(void) {
  int t;
  scanf("%d", &t);
  for (int love = 0, _n = (t); love < _n; love = love + 1) process();
  return 0;
}
