#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long>> shs = {make_pair(0, 1), make_pair(1, 0),
                                          make_pair(-1, 0), make_pair(0, -1)};
long long sgn(long long first) {
  if (first > 0) return 1;
  if (first < 0) return -1;
  return 0;
}
long long operator*(pair<long long, long long> a,
                    pair<long long, long long> b) {
  return a.first * b.first + a.second * b.second;
}
long long operator^(pair<long long, long long> a,
                    pair<long long, long long> b) {
  return a.first * b.second - a.second * b.first;
}
pair<long long, long long> operator-(pair<long long, long long> a,
                                     pair<long long, long long> b) {
  return make_pair(a.first - b.first, a.second - b.second);
}
pair<long long, long long> operator+(pair<long long, long long> a,
                                     pair<long long, long long> b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
bool is_ok(vector<pair<long long, long long>> pts) {
  set<long long> length;
  long long cnt = 0;
  for (long long i = 0; i < pts.size(); i++) {
    for (long long j = i + 1; j < pts.size(); j++) {
      if (pts[i].first == pts[j].first || pts[i].second == pts[j].second) {
        cnt++;
        length.insert(abs(pts[i].first - pts[j].first) +
                      abs(pts[i].second - pts[j].second));
      }
    }
  }
  return length.size() == 1 && cnt == 4;
}
bool target = false;
pair<long long, vector<pair<long long, long long>>> solve(
    vector<pair<long long, long long>> v) {
  if (is_ok(v)) {
    return make_pair(0, v);
  }
  long long rez = 1e18;
  vector<pair<long long, long long>> opt;
  for (long long mask = 0; mask < 256; mask++) {
    vector<pair<long long, long long>> dir;
    for (long long i = 0; i < 4; i++) {
      long long egor = 0;
      if (mask & (1 << (2 * i))) {
        egor += 2;
      }
      if (mask & (1 << (2 * i + 1))) {
        egor++;
      }
      dir.push_back(shs[egor]);
    }
    vector<pair<long long, long long>> pts;
    for (long long i = 0; i < 4; i++) {
      for (long long j = i + 1; j < 4; j++) {
        if (dir[i] * dir[j] == 0) {
          long long first = (dir[j].second == 0) ? v[i].first : v[j].first;
          long long second = (dir[j].first == 0) ? v[i].second : v[j].second;
          pts.emplace_back(first, second);
        }
      }
    }
    sort(pts.begin(), pts.end());
    pts.resize(unique(pts.begin(), pts.end()) - pts.begin());
    auto checkout = [&](vector<pair<long long, long long>> pts) {
      if (!is_ok(pts)) return;
      long long cur = 0;
      vector<bool> ok(4);
      sort(pts.begin(), pts.end());
      do {
        long long cur = 0;
        vector<bool> ok(4);
        for (long long i = 0; i < 4; i++) {
          pair<long long, long long> p = v[i];
          if (sgn(pts[i].first - p.first) == sgn(dir[i].first) &&
              sgn(pts[i].second - p.second) == sgn(dir[i].second)) {
            ok[i] = true;
            cur = max(cur, abs(pts[i].first - p.first) +
                               abs(pts[i].second - p.second));
          }
        }
        if (ok == vector<bool>(4, true)) {
          if (rez > cur) {
            rez = cur;
            opt = pts;
          }
        }
      } while (next_permutation(pts.begin(), pts.end()));
    };
    if (pts.size() >= 2) {
      pair<long long, long long> vec = pts[1] - pts[0];
      pair<long long, long long> rvec = make_pair(-vec.second, vec.first);
      pair<long long, long long> rvecvec = make_pair(vec.second, -vec.first);
      vector<pair<long long, long long>> A, B;
      A = vector<pair<long long, long long>>{pts[0], pts[1], pts[1] + rvec,
                                             pts[0] + rvec};
      checkout(A);
      A = vector<pair<long long, long long>>{pts[0], pts[1], pts[1] + rvecvec,
                                             pts[0] + rvecvec};
      checkout(A);
    }
  }
  auto checkout2 = [&](vector<pair<long long, long long>> pts) {
    if (!is_ok(pts)) return (long long)1e9;
    vector<bool> ok(4);
    sort(pts.begin(), pts.end());
    long long lc = 1e9;
    do {
      long long cur = 0;
      vector<bool> ok(4);
      for (long long i = 0; i < 4; i++) {
        pair<long long, long long> p = v[i];
        if ((pts[i].first - p.first) == 0 || (pts[i].second - p.second) == 0) {
          ok[i] = true;
          cur = max(
              cur, abs(pts[i].first - p.first) + abs(pts[i].second - p.second));
        }
      }
      if (ok == vector<bool>(4, true)) {
        if (lc > cur) {
          lc = cur;
        }
        if (rez > cur) {
          rez = cur;
          opt = pts;
        }
      }
    } while (next_permutation(pts.begin(), pts.end()));
    return lc;
  };
  {
    set<long long> ys;
    for (pair<long long, long long> p : v) {
      ys.insert(p.second);
    }
    if (ys.size() == 2) {
      long long d = (*ys.rbegin()) - (*ys.begin());
      long long low = *ys.begin();
      long long high = *ys.rbegin();
      long long l = -1e9;
      long long r = 1e9;
      while (r - l > 3) {
        long long m1 = (l + l + r) / 3;
        long long m2 = (l + r + r) / 3;
        if (checkout2(vector<pair<long long, long long>>{
                make_pair(m1, low), make_pair(m1, high), make_pair(m1 + d, low),
                make_pair(m1 + d, high)}) <
            checkout2(vector<pair<long long, long long>>{
                make_pair(m2, low), make_pair(m2, high), make_pair(m2 + d, low),
                make_pair(m2 + d, high)})) {
          r = m2;
        } else
          l = m1;
      }
      for (long long t = -10; t < 10; t++) {
        checkout2(vector<pair<long long, long long>>{
            make_pair(l + t, low), make_pair(l + t, high),
            make_pair(l + t + d, low), make_pair(l + t + d, high)});
      }
    }
  }
  if (rez > 1e12) {
    return make_pair(rez, vector<pair<long long, long long>>{});
  }
  return make_pair(rez, opt);
}
signed main() {
  long long tests;
  cin >> tests;
  for (long long test = 0; test < tests; test++) {
    vector<pair<long long, long long>> v(4);
    for (long long i = 0; i < 4; i++) {
      cin >> v[i].first >> v[i].second;
    }
    auto A = solve(v);
    for (long long i = 0; i < 4; i++) {
      v[i] = make_pair(-v[i].second, v[i].first);
    }
    auto B = solve(v);
    for (pair<long long, long long> &p : B.second) {
      p = make_pair(p.second, -p.first);
    }
    A = min(A, B);
    if (A.first > 1e12) {
      cout << -1 << endl;
    } else {
      cout << A.first << endl;
      for (pair<long long, long long> p : A.second) {
        cout << p.first << " " << p.second << endl;
      }
    }
  }
}
