#include <bits/stdc++.h>
using namespace std;
int X[4];
int Y[4];
int d[4];
const int N = 4;
struct ival {
  int low, high;
  ival() : low(-1000000000), high(1000000000) {}
  bool is_known() const { return low == high; }
  bool is_invalid() const { return low > high; }
  bool is_valid() const { return low <= high; }
  bool contains(int v) const { return low <= v && v <= high; }
  int get_min() const { return low; }
  int get_max() const { return high; }
  int get() const {
    assert(low == high);
    return low;
  }
  void set_min(int x) { low = max(low, x); }
  void set_max(int x) { high = min(high, x); }
  void set(int x) {
    set_min(x);
    set_max(x);
  }
  friend ostream& operator<<(ostream& out, const ival& me) {
    return out << "interval(lower_bound=" << me.low
               << ",upper_bound=" << me.high << ")";
  }
};
bool go2(int tl, int tr, int bl, int br, const int MAX_DIST, bool print) {
  ival top, right, bottom, left, size;
  if (d[tl] == 0)
    top.set(Y[tl]);
  else
    left.set(X[tl]);
  if (d[tr] == 0)
    top.set(Y[tr]);
  else
    right.set(X[tr]);
  if (d[br] == 0)
    bottom.set(Y[br]);
  else
    right.set(X[br]);
  if (d[bl] == 0)
    bottom.set(Y[bl]);
  else
    left.set(X[bl]);
  if (d[tl] == 0)
    left.set_min(X[tl] - MAX_DIST), left.set_max(X[tl] + MAX_DIST);
  else
    top.set_min(Y[tl] - MAX_DIST), top.set_max(Y[tl] + MAX_DIST);
  if (d[tr] == 0)
    right.set_min(X[tr] - MAX_DIST), right.set_max(X[tr] + MAX_DIST);
  else
    top.set_min(Y[tr] - MAX_DIST), top.set_max(Y[tr] + MAX_DIST);
  if (d[br] == 0)
    right.set_min(X[br] - MAX_DIST), right.set_max(X[br] + MAX_DIST);
  else
    bottom.set_min(Y[br] - MAX_DIST), bottom.set_max(Y[br] + MAX_DIST);
  if (d[bl] == 0)
    left.set_min(X[bl] - MAX_DIST), left.set_max(X[bl] + MAX_DIST);
  else
    bottom.set_min(Y[bl] - MAX_DIST), bottom.set_max(Y[bl] + MAX_DIST);
  size.set_min(1);
  if (top.is_known() && bottom.is_known()) size.set(top.get() - bottom.get());
  if (left.is_known() && right.is_known()) size.set(right.get() - left.get());
  if (size.is_invalid()) return false;
  if (!size.is_known()) {
    assert(top.is_invalid() || right.is_invalid() || bottom.is_invalid() ||
           left.is_invalid());
    return false;
  }
  assert(size.is_known());
  if (top.is_known()) bottom.set(top.get() - size.get());
  if (right.is_known()) left.set(right.get() - size.get());
  if (bottom.is_known()) top.set(bottom.get() + size.get());
  if (left.is_known()) right.set(left.get() + size.get());
  if (top.is_invalid()) return false;
  if (right.is_invalid()) return false;
  if (bottom.is_invalid()) return false;
  if (left.is_invalid()) return false;
  int real_top, real_right, real_bottom, real_left;
  if (left.is_known() && right.is_known()) {
    int closest = top.get_min() - bottom.get_max();
    int furthest = top.get_max() - bottom.get_min();
    if (closest > size.get()) return false;
    if (furthest < size.get()) return false;
    real_top = min(top.get_max(), bottom.get_max() + size.get());
    real_right = right.get();
    real_bottom = real_top - size.get();
    real_left = left.get();
  } else {
    assert(top.is_known() && bottom.is_known());
    int closest = right.get_min() - left.get_max();
    int furthest = right.get_max() - left.get_min();
    if (closest > size.get()) return false;
    if (furthest < size.get()) return false;
    real_top = top.get();
    real_right = min(right.get_max(), left.get_max() + size.get());
    real_bottom = bottom.get();
    real_left = real_right - size.get();
  }
  assert(top.contains(real_top));
  assert(right.contains(real_right));
  assert(bottom.contains(real_bottom));
  assert(left.contains(real_left));
  assert(real_right - real_left == size.get());
  assert(real_top - real_bottom == size.get());
  if (print) {
    printf("%d\n", MAX_DIST);
    for (int i = 0; i < (N); ++i) {
      int seen = 0;
      if (i == tl) printf("%d %d\n", real_left, real_top), ++seen;
      if (i == tr) printf("%d %d\n", real_right, real_top), ++seen;
      if (i == br) printf("%d %d\n", real_right, real_bottom), ++seen;
      if (i == bl) printf("%d %d\n", real_left, real_bottom), ++seen;
      assert(seen == 1);
    }
  }
  return true;
}
bool go(int MAX_DIST, bool print) {
  for (int tl = 0; tl < (N); ++tl)
    for (int tr = 0; tr < (N); ++tr)
      if (tr != tl)
        for (int bl = 0; bl < (N); ++bl)
          if (bl != tl && bl != tr)
            for (int br = 0; br < (N); ++br)
              if (br != tl && br != tr && br != bl)
                for (d[tl] = 0; d[tl] < (2); ++d[tl])
                  for (d[tr] = 0; d[tr] < (2); ++d[tr])
                    for (d[bl] = 0; d[bl] < (2); ++d[bl])
                      for (d[br] = 0; d[br] < (2); ++d[br]) {
                        if (go2(tl, tr, bl, br, MAX_DIST, print)) return true;
                      }
  return false;
}
void test() {
  for (int i = 0; i < (N); ++i) scanf("%d%d", &X[i], &Y[i]);
  const int BIG = 1000000000;
  int low = 0;
  int high = BIG;
  while (low < high) {
    int k = (low + high) / 2;
    if (go(k, false))
      high = k;
    else
      low = k + 1;
  }
  if (low == BIG || low > high) {
    printf("-1\n");
  } else {
    assert(low == high);
    go(low, true);
  }
}
int main() {
  int TEST;
  scanf("%d", &TEST);
  for (int _ = 0; _ < (TEST); ++_) test();
}
