#include <bits/stdc++.h>
using namespace std;
int inf;
const double eps = 1e-8;
const double pi = acos(-1.0);
template <class T>
int chkmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
int chkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
T sqr(T a) {
  return a * a;
}
template <class T>
T mmin(T a, T b) {
  return a < b ? a : b;
}
template <class T>
T mmax(T a, T b) {
  return a > b ? a : b;
}
template <class T>
T aabs(T a) {
  return a < 0 ? -a : a;
}
template <class T>
int dcmp(T a, T b) {
  return a > b;
}
template <int *a>
int cmp_a(int first, int second) {
  return a[first] < a[second];
}
struct __INIT__ {
  __INIT__() { memset(&inf, 0x3f, sizeof(inf)); }
} __INIT___;
namespace io {
const int SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c,
                                       qu[55];
int f, qr;
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char first) {
  *oS++ = first;
  if (oS == oT) flush();
}
template <typename A>
inline bool read(A &first) {
  for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                            : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-')
      f = -1;
    else if (c == EOF)
      return 0;
  for (first = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    first = first * 10 + (c & 15);
  first *= f;
  return 1;
}
inline bool read(char &first) {
  while ((first = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                               (iS == iT ? EOF : *iS++))
                            : *iS++)) == ' ' ||
         first == '\n' || first == '\r')
    ;
  return first != EOF;
}
inline bool read(char *first) {
  while ((*first = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                                (iS == iT ? EOF : *iS++))
                             : *iS++)) == '\n' ||
         *first == ' ' || *first == '\r')
    ;
  if (*first == EOF) return 0;
  while (!(*first == '\n' || *first == ' ' || *first == '\r' || *first == EOF))
    *(++first) = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                           : *iS++);
  *first = 0;
  return 1;
}
template <typename A, typename... B>
inline bool read(A &first, B &...second) {
  return read(first) && read(second...);
}
template <typename A>
inline bool write(A first) {
  if (!first) putc('0');
  if (first < 0) putc('-'), first = -first;
  while (first) qu[++qr] = first % 10 + '0', first /= 10;
  while (qr) putc(qu[qr--]);
  return 0;
}
inline bool write(char first) {
  putc(first);
  return 0;
}
inline bool write(const char *first) {
  while (*first) {
    putc(*first);
    ++first;
  }
  return 0;
}
inline bool write(char *first) {
  while (*first) {
    putc(*first);
    ++first;
  }
  return 0;
}
template <typename A, typename... B>
inline bool write(A first, B... second) {
  return write(first) || write(second...);
}
struct Flusher_ {
  ~Flusher_() { flush(); }
} io_flusher_;
}  // namespace io
using io ::putc;
using io ::read;
using io ::write;
pair<int, int> a[5], ap[5], po[5];
int b[5], ans, c[5], d[5];
int query(pair<int, int> a, pair<int, int> b, int id) {
  if (id == 2) {
    if (a.second != b.second) return inf;
    return aabs(b.first - a.first);
  } else {
    if (a.first != b.first) return inf;
    return aabs(b.second - a.second);
  }
}
void chk(int x1, int x2, int y1, int y2) {
  po[1] = make_pair(x1, y1);
  po[2] = make_pair(x2, y1);
  po[3] = make_pair(x1, y2);
  po[4] = make_pair(x2, y2);
  d[1] = 1;
  d[2] = 2;
  d[3] = 3;
  d[4] = 4;
  do {
    int mx = 0;
    for (int i = 1; i <= 4; ++i) chkmax(mx, query(a[i], po[d[i]], c[i]));
    if (chkmin(ans, mx)) {
      for (int i = 1; i <= 4; ++i) ap[i] = po[d[i]];
    };
  } while (next_permutation(d + 1, d + 5));
}
vector<int> xx, yy;
vector<int> v1, v2;
void calc() {
  xx.clear();
  yy.clear();
  for (int i = 1; i <= 4; ++i)
    if (c[i] == 1)
      xx.push_back(a[i].first);
    else
      yy.push_back(a[i].second);
  sort(xx.begin(), xx.end());
  xx.erase(unique(xx.begin(), xx.end()), xx.end());
  sort(yy.begin(), yy.end());
  yy.erase(unique(yy.begin(), yy.end()), yy.end());
  if (xx.size() > 2 || yy.size() > 2) return;
  if (xx.size() <= 1 && yy.size() <= 1) return;
  if (xx.size() == 2 && yy.size() == 2) {
    if (xx[1] - xx[0] == yy[1] - yy[0]) chk(xx[0], xx[1], yy[0], yy[1]);
  } else if (xx.size() == 2) {
    int r = xx[1] - xx[0];
    if (yy.size() == 1) {
      chk(xx[0], xx[1], yy[0] - r, yy[0]);
      chk(xx[0], xx[1], yy[0], yy[0] + r);
    } else {
      v1.clear();
      v2.clear();
      for (int i = 1; i <= 4; ++i)
        if (a[i].first == xx[0]) {
          v1.push_back(a[i].second);
        } else
          v2.push_back(a[i].second);
      if (v1.size() != 2) return;
      sort(v1.begin(), v1.end());
      sort(v2.begin(), v2.end());
      v1[1] -= r;
      v2[1] -= r;
      v1.push_back(v2[0]);
      v1.push_back(v2[1]);
      sort(v1.begin(), v1.end());
      int mid = (v1[3] + v1[0]) >> 1;
      chk(xx[0], xx[1], mid, mid + r);
    }
  } else {
    int r = yy[1] - yy[0];
    if (xx.size() == 1) {
      chk(xx[0] - r, xx[0], yy[0], yy[1]);
      chk(xx[0], xx[0] + r, yy[0], yy[1]);
    } else {
      v1.clear();
      v2.clear();
      for (int i = 1; i <= 4; ++i)
        if (a[i].second == yy[0]) {
          v1.push_back(a[i].first);
        } else
          v2.push_back(a[i].first);
      if (v1.size() != 2) return;
      sort(v1.begin(), v1.end());
      sort(v2.begin(), v2.end());
      v1[1] -= r;
      v2[1] -= r;
      v1.push_back(v2[0]);
      v1.push_back(v2[1]);
      sort(v1.begin(), v1.end());
      int mid = (v1[3] + v1[0]) >> 1;
      chk(mid, mid + r, yy[0], yy[1]);
    }
  }
}
signed main() {
  int t;
  read(t);
  for (; t; --t) {
    for (int i = 1; i <= 4; ++i) {
      read(a[i].first, a[i].second);
    }
    ans = inf;
    for (int i = 0; i < 16; ++i) {
      for (int j = 1; j <= 4; ++j) c[j] = (i & (1 << (j - 1))) ? 1 : 2;
      calc();
    }
    if (ans == inf) {
      write("-1\n");
    } else {
      write(ans, '\n');
      for (int i = 1; i <= 4; ++i) write(ap[i].first, ' ', ap[i].second, '\n');
    }
  }
  return 0;
}
