#include<bits/stdc++.h>
using namespace std;
#define pb  push_back
#define ll  long long
#define vi  vector<ll >
#define vvi vector<vi >
#define all(x) x.begin(), x.end()

ll sq(ll x) { return x * x; }

ll ss(ll x, ll y) { return sq(x) + sq(y); }

ll a[7], b[7];

bool okk(ll cx, ll cy) {
    ll mi, ma;
    mi = 3000000;
    ma = 0;
    for (ll i = 0; i < 6; ++i) {
        ll len = ss(a[i] - cx, b[i] - cy);
        mi = min(mi, len);
        ma = max(ma, len);
    }
    if (10000 * ma > 12321 * mi) return false;
    return true;
}

bool ok() {
    ll mi, ma;
    mi = 3000000;
    ma = 0;
    for (ll i = 0; i < 6; ++i) {
        ll len = ss(a[i] - a[i + 1], b[i] - b[i + 1]);
        mi = min(mi, len);
        ma = max(ma, len);
    }
    if (10000 * ma > 12321 * mi) return false;

    mi = 3000000;
    ma = 0;
    for (ll i = 0; i < 3; ++i) {
        ll len = ss(a[i] - a[i + 3], b[i] - b[i + 3]);
        mi = min(mi, len);
        ma = max(ma, len);
    }
    if (10000 * ma > 12321 * mi) return false;

    ll cx = 0, cy = 0;
    for (ll i = 0; i < 6; ++i) {
        cx += a[i];
        cy += b[i];
    }
    cx /= 6; cy /= 6;
    for (ll dx = 0; dx < 50; ++dx) {
        for (ll dy = 0; dy < 50; ++dy) {
            if (okk(cx + dx, cx + dy)) return true;
            if (okk(cx + dx, cx - dy)) return true;
            if (okk(cx - dx, cx + dy)) return true;
            if (okk(cx - dx, cx - dy)) return true;
        }
    }
    return false;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    ll t; cin >> t;
    string s = string(t, '0');
    for (ll e = 0; e < t; ++e) {
        for (ll i = 0; i < 6; ++i)
            cin >> a[i] >> b[i];
        a[6] = a[0];
        b[6] = b[0];
        if (ok()) ++s[e];
    }
    cout << s << endl;

    return 0;
}
