func_code_string: #include <bits/stdc++.h>   using namespace std;   namespace std {   bool operator<(const complex<double> &lhs, const complex<double> &rhs) {     if (real(lhs) == real(rhs)) {       return imag(lhs) < imag(rhs);     } else {       return real(lhs) < real(rhs);     }   }   }  // namespace std   ostream &operator<<(ostream &os, const complex<double> &p) {     return os <<  (  << p.real() <<  ,  << p.imag() <<  ) ;   }   template <typename T>   ostream &operator<<(ostream &os, const vector<T> &vec) {     os <<  [ ;     for (const auto &v : vec) {       os << v <<  , ;     }     os <<  ] ;     return os;   }   complex<double> counter_clock_wise(complex<double> p, double rad) {     double a = abs(p);     return polar(a, arg(p) + rad);   }   const double EPS = 1e-7;   const double PI = 3.141592653589793;   double dot(complex<double> a, complex<double> b) { return real(conj(a) * b); }   double point_distance(complex<double> a, complex<double> b) {     return abs(a - b);   }   bool is_square(vector<complex<double> > ps) {     sort(ps.begin(), ps.end());     vector<double> dist;     for (long long i = 0; i < 4; i++) {       for (long long j = i + 1; j < 4; j++) {         if (abs(ps[i] - ps[j]) < EPS) return false;         dist.push_back(abs(ps[i] - ps[j]));       }     }     sort(dist.begin(), dist.end());     for (long long i = 0; i < 4; i++) {       if (abs(dist[0] - dist[i]) > EPS) return false;     }     for (long long i = 4; i < 6; i++) {       if (abs(sqrt(2) * dist[1] - dist[i]) > EPS) return false;     }     return true;   }   const long long INF = 100000000;   long long solve(vector<long long> y, vector<long long> x, vector<long long> b,                   vector<long long> a) {     long long ret = INF;     ;     ;     for (long long i = 0; i < static_cast<long long>(4); i++) {       for (long long j = 0; j < static_cast<long long>(4); j++) {         for (long long k = 0; k < static_cast<long long>(4); k++) {           for (long long l = 0; l < static_cast<long long>(4); l++) {             vector<long long> cur = {i, j, k, l};             vector<complex<double> > ps;             for (long long m = 0; m < static_cast<long long>(4); m++) {               complex<double> p(x[m], y[m]);               p -= complex<double>(a[m], b[m]);               p = counter_clock_wise(p, (PI / 2) * cur[m]);               p += complex<double>(a[m], b[m]);               ps.push_back(p);             }             sort(ps.begin(), ps.end());             if (is_square(ps)) {               ;               ;               ret = min(ret, i + j + k + l);             }           }         }       }     }     if (ret == INF) return -1;     return ret;   }   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     long long n;     cin >> n;     for (long long i = 0; i < n; i++) {       vector<long long> y(4), x(4), b(4), a(4);       for (long long j = 0; j < 4; j++) {         cin >> x[j] >> y[j] >> a[j] >> b[j];       }       long long ret = solve(y, x, b, a);       cout << ret << endl;     }     return 0;   }   