#include <bits/stdc++.h>

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

struct Vector {
    ll x, y, i;
    Vector(ll x = 0, ll y = 0, ll i = 0) : x(x), y(y), i(i) { }
    Vector operator-(const Vector& other) const {
        return Vector(x - other.x, y - other.y, i);
    }
    ll get_len2() const {
        return 1ll * x * x + 1ll * y * y;
    }
};

ll crossp(const Vector& a, const Vector& b) {
    return 1ll * a.x * b.y - 1ll * a.y * b.x;
}

bool check(vector<Vector> p, vvi poly) {
    int n = sz(p);
    Vector pmin = p[0];
    for (int i = 0; i < n; ++i) {
        if (p[i].x < pmin.x) {
            pmin = p[i];
        } else if (pmin.x == p[i].x && p[i].y < pmin.y) {
            pmin = p[i];
        }
    }
    for (int i = 0; i < n; ++i) {
        p[i] = p[i] - pmin;
    }
    sort(all(p), [&] (const Vector& a, const Vector& b) {
        ll c = crossp(a, b);
        if (c == 0) {
            return a.get_len2() < b.get_len2();
        }
        return c > 0;
    });
    vi ch;
    for (int i = 0; i < n; ++i) {
        while (sz(ch) >= 2 && crossp(p[ch.back()] - p[ch[sz(ch) - 2]], p[i] - p[ch.back()]) <= 0) {
            ch.pop_back();
        }
        ch.pb(i);
    }
    vvi gr(n);
    for (int i = 0; i < sz(poly); ++i) {
        for (int j = 0; j + 1 < sz(poly[i]); ++j) {
            gr[poly[i][j]].pb(poly[i][j + 1]);
        }
        gr[poly[i].back()].pb(poly[i][0]);
    }
    for (int i = sz(ch) - 1; i > 0; --i) {
        gr[p[ch[i]].i].pb(p[ch[i - 1]].i);
    }
    gr[p[ch[0]].i].pb(p[ch.back()].i);
    for (int i = 0; i < n; ++i) {
        sort(all(gr[i]));
    }
    for (int u = 0; u < n; ++u) {
        for (int v : gr[u]) {
            auto it = lower_bound(all(gr[v]), u) - gr[v].begin();
            if (it >= sz(gr[v]) || gr[v][it] != u) {
                return false;
            }
        }
    }
    return true;
}
