#include <bits/stdc++.h>
using namespace std;
int T;
pair<int, int> a[4], b[4];
pair<int, vector<pair<int, int> > > ans;
int calc(pair<int, int> p, pair<int, int> q) {
  if (p.first == q.first) return abs(p.second - q.second);
  if (p.second == q.second) return abs(p.first - q.first);
  return 1 << 30;
}
void check(int first, int second, int z) {
  vector<pair<int, int> > vec = {{first, second},
                                 {first, second + z},
                                 {first + z, second},
                                 {first + z, second + z}};
  do {
    int res = 0;
    for (int i = 0; i < 4; ++i) res = max(res, calc(a[i], vec[i]));
    ans = min(ans, {res, vec});
  } while (next_permutation(vec.begin(), vec.end()));
}
int main() {
  scanf("%d", &T);
  while (T--) {
    for (int i = 0; i < 4; ++i)
      scanf("%d%d", &a[i].first, &a[i].second), b[i] = a[i];
    ans.first = 1 << 30;
    sort(b, b + 4);
    if (b[0].first == b[1].first && b[1].first < b[2].first &&
        b[2].first == b[3].first) {
      int len = b[2].first - b[1].first;
      for (int i = 0; i < 2; ++i)
        for (int j = 2; j < 4; ++j) {
          b[i].second -= len;
          b[j].second -= len;
          int mn = 1 << 30, mx = -1 << 30;
          for (int k = 0; k < 4; ++k)
            mn = min(mn, b[k].second), mx = max(mx, b[k].second);
          check(b[0].first, mx + mn >> 1, len);
          b[i].second += len;
          b[j].second += len;
        }
    }
    for (int i = 0; i < 4; ++i) swap(b[i].first, b[i].second);
    sort(b, b + 4);
    for (int i = 0; i < 4; ++i) swap(b[i].first, b[i].second);
    if (b[0].second == b[1].second && b[1].second < b[2].second &&
        b[2].second == b[3].second) {
      int len = b[2].second - b[1].second;
      for (int i = 0; i < 2; ++i)
        for (int j = 2; j < 4; ++j) {
          b[i].first -= len;
          b[j].first -= len;
          int mn = 1 << 30, mx = -1 << 30;
          for (int k = 0; k < 4; ++k)
            mn = min(mn, b[k].first), mx = max(mx, b[k].first);
          check(mx + mn >> 1, b[0].second, len);
          b[i].first += len;
          b[j].first += len;
        }
    }
    for (int i = 1; i < 15; ++i) {
      int first, second, z = 0;
      for (int j = 0; j < 4; ++j)
        for (int k = j + 1; k < 4; ++k)
          if ((i >> j & 1) == (i >> k & 1))
            if (i >> j & 1)
              z ? z : z = abs(b[j].first - b[k].first);
            else
              z ? z : z = abs(b[j].second - b[k].second);
          else if (i >> j & 1)
            first = b[j].first, second = b[k].second;
          else
            first = b[k].first, second = b[j].second;
      check(first - z, second - z, z);
      check(first - z, second, z);
      check(first, second - z, z);
      check(first, second, z);
    }
    if (ans.first == 1 << 30)
      puts("-1");
    else {
      printf("%d\n", ans.first);
      for (int i = 0; i < 4; ++i)
        printf("%d %d\n", ans.second[i].first, ans.second[i].second);
    }
  }
  return 0;
}
