#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define debug(X) cerr << " --> " << #X << " = " << X << endl
#define mod 1000000007LL
#define inf 1123456789123456789LL
#define endl "\n"
typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pii; typedef vector<pii> vpii;
const int N = 512345, lgN = 20, rootN = 1123;
const double eps = 1e-11;
int r[N], w[N];
vector<double> positive, negative;
bool comp(double a, double b)
{
    if(abs(a - b) > eps && a < b)
        return true;
    else
        return false;
}
map<int, int> compress;
int bit[N];
void update(int v, int val)
{
    while(v < N)
    {
        bit[v] += val;
        v += (v & (-v));
    }
}
int query(int v)
{
    int ret = 0;
    while(v)
    {
        ret += bit[v];
        v -= (v & (-v));
    }
    return ret;
}
vector<pair<double, int>> all;
vi compression;
int main()
{
    int n, c, d;
    cin>>n>>c>>d;
    for(int i = 1; i <= n; ++i)
    {
        cin>>r[i]>>w[i];
        r[i] -= c, w[i] -= d;
    }
    for(int i = 1; i <= n; ++i)
    {
        if(w[i] > 0)
        {
            positive.pb(((double)r[i]) / w[i]);
        }
        else if(w[i] < 0)
        {
            negative.pb(((double)r[i]) / w[i]);
        }
        compression.pb(w[i]);
    }
    sort(compression.begin(), compression.end());
    for(int i = 0, ct = 1; i < compression.size(); ++i)
    {
        if(i == 0 || compression[i] > compression[i - 1])
            compress[compression[i]] = ct++;
    }
    sort(positive.begin(), positive.end(), comp);
    sort(negative.begin(), negative.end(), comp);

    ll first = 0, second = 0;
    for(int i = 0; i < positive.size(); ++i)
    {
        first += (lower_bound(negative.begin(), negative.end(), positive[i], comp) - negative.begin());
    }
    for(int i = 0; i < negative.size(); ++i)
    {
        second += (lower_bound(positive.begin(), positive.end(), negative[i], comp) - positive.begin());
    }
    ll ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        if(w[i] > 0)
        {
            ans += (negative.end() - upper_bound(negative.begin(), negative.end(), ((double)r[i]) / w[i], comp)) * (lower_bound(negative.begin(), negative.end(), ((double)r[i]) / w[i], comp) - negative.begin());
        }
        else if(w[i] < 0)
        {
            ans += (positive.end() - upper_bound(positive.begin(), positive.end(), ((double)r[i]) / w[i], comp)) * (lower_bound(positive.begin(), positive.end(), ((double)r[i]) / w[i], comp) - positive.begin());
        }
        else if(w[i] == 0)
        {
            if(r[i] > 0)
                ans += first;
            else
                ans += second;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define debug(X) cerr << " --> " << #X << " = " << X << endl
#define mod 1000000007LL
#define inf 1123456789123456789LL
#define endl "\n"
typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pii; typedef vector<pii> vpii;
const int N = 512345, lgN = 20, rootN = 1123;
const double eps = 1e-11;
int r[N], w[N];
vector<double> positive, negative;
bool comp(double a, double b)
{
    if(abs(a - b) > eps && a < b)
        return true;
    else
        return false;
}
map<int, int> compress;
int bit[N];
void update(int v, int val)
{
    while(v < N)
    {
        bit[v] += val;
        v += (v & (-v));
    }
}
int query(int v)
{
    int ret = 0;
    while(v)
    {
        ret += bit[v];
        v -= (v & (-v));
    }
    return ret;
}
vector<pair<double, int>> all;
vi compression;
int main()
{
    int n, c, d;
    cin>>n>>c>>d;
    for(int i = 1; i <= n; ++i)
    {
        cin>>r[i]>>w[i];
        r[i] -= c, w[i] -= d;
    }
    for(int i = 1; i <= n; ++i)
    {
        if(w[i] > 0)
        {
            positive.pb(((double)r[i]) / w[i]);
        }
        else if(w[i] < 0)
        {
            negative.pb(((double)r[i]) / w[i]);
        }
        compression.pb(w[i]);
    }
    sort(compression.begin(), compression.end());
    for(int i = 0, ct = 1; i < compression.size(); ++i)
    {
        if(i == 0 || compression[i] > compression[i - 1])
            compress[compression[i]] = ct++;
    }
    sort(positive.begin(), positive.end(), comp);
    sort(negative.begin(), negative.end(), comp);

    ll first = 0, second = 0;
    for(int i = 1; i <= n; ++i)
    {
        if(w[i] > 0)
            all.pb(mp(((double)r[i]) / w[i], w[i]));
    }
    sort(all.begin(), all.end());
    memset(bit, 0, sizeof bit);
    for(int i = 0; i < all.size(); ++i)
    {
        int ww = compress[all[i].S];
        first += query(ww - 1);
        second += i - query(ww);
        update(ww, 1);
    }
    all.clear();
    for(int i = 1; i <= n; ++i)
    {
        if(w[i] < 0)
            all.pb(mp(((double)r[i]) / w[i], w[i]));
    }
    sort(all.begin(), all.end());
    memset(bit, 0, sizeof bit);
    for(int i = 0; i < all.size(); ++i)
    {
        int ww = compress[all[i].S];
        first += query(ww - 1);
        second += i - query(ww);
        update(ww, 1);
    }
    for(int i = 0; i < positive.size(); ++i)
    {
        first += (lower_bound(negative.begin(), negative.end(), positive[i], comp) - negative.begin());
    }
    for(int i = 0; i < negative.size(); ++i)
    {
        second += (lower_bound(positive.begin(), positive.end(), negative[i], comp) - positive.begin());
    }

    ll ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        if(w[i] > 0)
        {
            ans += (negative.end() - upper_bound(negative.begin(), negative.end(), ((double)r[i]) / w[i], comp)) * (lower_bound(negative.begin(), negative.end(), ((double)r[i]) / w[i], comp) - negative.begin());
        }
        else if(w[i] < 0)
        {
            ans += (positive.end() - upper_bound(positive.begin(), positive.end(), ((double)r[i]) / w[i], comp)) * (lower_bound(positive.begin(), positive.end(), ((double)r[i]) / w[i], comp) - positive.begin());
        }
        else if(w[i] == 0)
        {
            if(r[i] > 0)
                ans += first;
            else
                ans += second;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define debug(X) cerr << " --> " << #X << " = " << X << endl
#define mod 1000000007LL
#define inf 1123456789123456789LL
#define endl "\n"
typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pii; typedef vector<pii> vpii;
const int N = 512345, lgN = 20, rootN = 1123;
const double eps = 1e-11;
int r[N], w[N];
vector<double> positive, negative;
int main()
{
    int n, c, d;
    cin>>n>>c>>d;
    for(int i = 1; i <= n; ++i)
    {
        cin>>r[i]>>w[i];
        r[i] -= c, w[i] -= d;
    }
    for(int i = 1; i <= n; ++i)
    {
        double x = (((double)r[i]) / w[i]);
        if(w[i] > 0)
        {
            positive.pb(x);
        }
        else if(w[i] < 0)
        {
            negative.pb(x);
        }
    }

    sort(positive.begin(), positive.end());
    sort(negative.begin(), negative.end());

    ll first = 0, second = 0;
    for(int i = 0; i < positive.size(); ++i)
    {
        first += (lower_bound(negative.begin(), negative.end(), positive[i]) - negative.begin());
    }
    for(int i = 0; i < negative.size(); ++i)
    {
        second += (lower_bound(positive.begin(), positive.end(), negative[i]) - positive.begin());
    }

    ll ans = 0;
    for(int i = 1; i <= n; ++i)
    {

        if(w[i] > 0)
        {double x = (((double)r[i]) / w[i]);

            ans += ((long long)(negative.end() - upper_bound(negative.begin(), negative.end(), x))) * (lower_bound(negative.begin(), negative.end(), x) - negative.begin());
        }
        else if(w[i] < 0)
        {double x = (((double)r[i]) / w[i]);
            ans += ((long long)(positive.end() - upper_bound(positive.begin(), positive.end(), x))) * (lower_bound(positive.begin(), positive.end(), x) - positive.begin());
        }
        else if(w[i] == 0)
        {
            if(r[i] < 0)
                ans += first;
            else
                ans += second;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define debug(X) cerr << " --> " << #X << " = " << X << endl
#define mod 1000000007LL
#define inf 1123456789123456789LL
#define endl "\n"
typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pii; typedef vector<pii> vpii;
const int N = 512345, lgN = 20, rootN = 1123;
const double eps = 1e-11;
int r[N], w[N];
vector<double> positive, negative;
double p[N];
int main()
{
    int n, c, d;
    cin>>n>>c>>d;
    for(int i = 1; i <= n; ++i)
    {
        cin>>r[i]>>w[i];
        r[i] -= c, w[i] -= d;
        p[i] = (((double)r[i]) / (double)w[i]);
    }
    for(int i = 1; i <= n; ++i)
    {
        double x = (((double)r[i]) / (double)w[i]);
        cerr<<x<<" "<<p[i]<<endl;
        assert(x == p[i]);
        if(w[i] > 0)
        {
            positive.pb(x);
        }
        else if(w[i] < 0)
        {
            negative.pb(x);
        }
    }

    sort(positive.begin(), positive.end());
    sort(negative.begin(), negative.end());

    ll first = 0, second = 0;
    for(int i = 0; i < positive.size(); ++i)
    {
        first += (lower_bound(negative.begin(), negative.end(), positive[i]) - negative.begin());
    }
    for(int i = 0; i < negative.size(); ++i)
    {
        second += (lower_bound(positive.begin(), positive.end(), negative[i]) - positive.begin());
    }

    ll ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        double x = (((double)r[i]) / (double)w[i]);
        if(w[i] > 0)
        {
            assert(abs(x - p[i]) < eps);
            ans += ((long long)(negative.end() - upper_bound(negative.begin(), negative.end(), x))) * (lower_bound(negative.begin(), negative.end(), x) - negative.begin());
        }
        else if(w[i] < 0)
        {
            assert(abs(x - p[i]) < eps);
            ans += ((long long)(positive.end() - upper_bound(positive.begin(), positive.end(), x))) * (lower_bound(positive.begin(), positive.end(), x) - positive.begin());
        }
        else if(w[i] == 0)
        {
            if(r[i] < 0)
                ans += first;
            else
                ans += second;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define debug(X) cerr << " --> " << #X << " = " << X << endl
#define mod 1000000007LL
#define inf 1123456789123456789LL
#define endl "\n"
typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pii; typedef vector<pii> vpii;
const int N = 512345, lgN = 20, rootN = 1123;
const double eps = 1e-18;
int r[N], w[N];
vector<double> positive, negative;
double p[N];
int main()
{
    int n, c, d;
    cin>>n>>c>>d;
    for(int i = 1; i <= n; ++i)
    {
        cin>>r[i]>>w[i];
        r[i] -= c, w[i] -= d;
        p[i] = (((double)r[i]) / (double)w[i]);
    }
    for(int i = 1; i <= n; ++i)
    {
        if(w[i] > 0)
        {
            positive.pb(p[i]);
        }
        else if(w[i] < 0)
        {
            negative.pb(p[i]);
        }
    }

    sort(positive.begin(), positive.end());
    sort(negative.begin(), negative.end());

    ll first = 0, second = 0;
    for(int i = 0; i < positive.size(); ++i)
    {
        first += (lower_bound(negative.begin(), negative.end(), positive[i]) - negative.begin());
    }
    for(int i = 0; i < negative.size(); ++i)
    {
        second += (lower_bound(positive.begin(), positive.end(), negative[i]) - positive.begin());
    }

    ll ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        if(w[i] > 0)
        {
            ans += ((long long)(negative.end() - upper_bound(negative.begin(), negative.end(), p[i]))) * (lower_bound(negative.begin(), negative.end(), p[i]) - negative.begin());
        }
        else if(w[i] < 0)
        {
            ans += ((long long)(positive.end() - upper_bound(positive.begin(), positive.end(), p[i]))) * (lower_bound(positive.begin(), positive.end(), p[i]) - positive.begin());
        }
        else if(w[i] == 0)
        {
            if(r[i] < 0)
                ans += first;
            else
                ans += second;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define debug(X) cerr << " --> " << #X << " = " << X << endl
#define mod 1000000007LL
#define inf 1123456789123456789LL
#define endl "\n"
typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pii; typedef vector<pii> vpii;
const int N = 512345, lgN = 20, rootN = 1123;
const double eps = 1e-11;
int r[N], w[N];
vector<double> positive, negative;
int main()
{
    int n, c, d;
    cin>>n>>c>>d;
    for(int i = 1; i <= n; ++i)
    {
        cin>>r[i]>>w[i];
        r[i] -= c, w[i] -= d;
    }
    for(int i = 1; i <= n; ++i)
    {
        if(w[i] > 0)
        {
            positive.pb(((double)r[i]) / w[i]);
        }
        else if(w[i] < 0)
        {
            negative.pb(((double)r[i]) / w[i]);
        }
    }

    sort(positive.begin(), positive.end());
    sort(negative.begin(), negative.end());

    ll first = 0, second = 0;
    for(int i = 0; i < positive.size(); ++i)
    {
        first += (lower_bound(negative.begin(), negative.end(), positive[i]) - negative.begin());
    }
    for(int i = 0; i < negative.size(); ++i)
    {
        second += (lower_bound(positive.begin(), positive.end(), negative[i]) - positive.begin());
    }
    ll ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        if(w[i] > 0)
        {
            ans += (negative.end() - upper_bound(negative.begin(), negative.end(), ((double)r[i]) / w[i])) * (lower_bound(negative.begin(), negative.end(), ((double)r[i]) / w[i]) - negative.begin());
        }
        else if(w[i] < 0)
        {
            ans += (positive.end() - upper_bound(positive.begin(), positive.end(), ((double)r[i]) / w[i])) * (lower_bound(positive.begin(), positive.end(), ((double)r[i]) / w[i]) - positive.begin());
        }
        else if(w[i] == 0)
        {
            if(r[i] < 0)
                ans += first;
            else
                ans += second;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define debug(X) cerr << " --> " << #X << " = " << X << endl
#define mod 1000000007LL
#define inf 1123456789123456789LL
#define endl "\n"
typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pii; typedef vector<pii> vpii;
const int N = 512345, lgN = 20, rootN = 1123;
const double eps = 1e-18;
int r[N], w[N];
vector<double> positive, negative;
double p[N];
int main()
{
    int n, c, d;
    cin>>n>>c>>d;
    for(int i = 1; i <= n; ++i)
    {
        cin>>r[i]>>w[i];
        r[i] -= c, w[i] -= d;
        p[i] = (((double)r[i]) / (double)w[i]);
    }
    for(int i = 1; i <= n; ++i)
    {
        double x = (((double)r[i]) / (double)w[i]);
        if(w[i] > 0)
        {
            positive.pb(x);
        }
        else if(w[i] < 0)
        {
            negative.pb(x);
        }
    }

    sort(positive.begin(), positive.end());
    sort(negative.begin(), negative.end());

    ll first = 0, second = 0;
    for(int i = 0; i < positive.size(); ++i)
    {
        first += (lower_bound(negative.begin(), negative.end(), positive[i]) - negative.begin());
    }
    for(int i = 0; i < negative.size(); ++i)
    {
        second += (lower_bound(positive.begin(), positive.end(), negative[i]) - positive.begin());
    }

    ll ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        double x = (((double)r[i]) / (double)w[i]);
        if(w[i])
        {
            if(abs(x - p[i]) >= eps)
            {
                cout<<i<<" "<<x<<" "<<p[i]<<" "<<(x - p[i])<<endl;
            }
        }
        if(w[i] > 0)
        {
            ans += ((long long)(negative.end() - upper_bound(negative.begin(), negative.end(), p[i]))) * (lower_bound(negative.begin(), negative.end(), p[i]) - negative.begin());
        }
        else if(w[i] < 0)
        {
            ans += ((long long)(positive.end() - upper_bound(positive.begin(), positive.end(), p[i]))) * (lower_bound(positive.begin(), positive.end(), p[i]) - positive.begin());
        }
        else if(w[i] == 0)
        {
            if(r[i] < 0)
                ans += first;
            else
                ans += second;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define debug(X) cerr << " --> " << #X << " = " << X << endl
#define mod 1000000007LL
#define inf 1123456789123456789LL
#define endl "\n"
typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pii; typedef vector<pii> vpii;
const int N = 512345, lgN = 20, rootN = 1123;
const double eps = 1e-11;
int r[N], w[N];
vector<double> positive, negative;
int main()
{
    int n, c, d;
    cin>>n>>c>>d;
    for(int i = 1; i <= n; ++i)
    {
        cin>>r[i]>>w[i];
        r[i] -= c, w[i] -= d;
    }
    for(int i = 1; i <= n; ++i)
    {
        if(w[i] > 0)
        {
            positive.pb((((double)r[i]) / w[i]));
        }
        else if(w[i] < 0)
        {
            negative.pb((((double)r[i]) / w[i]));
        }
    }

    sort(positive.begin(), positive.end());
    sort(negative.begin(), negative.end());

    ll first = 0, second = 0;
    for(int i = 0; i < positive.size(); ++i)
    {
        first += (lower_bound(negative.begin(), negative.end(), positive[i]) - negative.begin());
    }
    for(int i = 0; i < negative.size(); ++i)
    {
        second += (lower_bound(positive.begin(), positive.end(), negative[i]) - positive.begin());
    }

    ll ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        if(w[i] > 0)
        {
            ans += ((long long)(negative.end() - upper_bound(negative.begin(), negative.end(), (((double)r[i]) / w[i])))) * (lower_bound(negative.begin(), negative.end(), (((double)r[i]) / w[i])) - negative.begin());
        }
        else if(w[i] < 0)
        {
            ans += ((long long)(positive.end() - upper_bound(positive.begin(), positive.end(), (((double)r[i]) / w[i])))) * (lower_bound(positive.begin(), positive.end(), (((double)r[i]) / w[i])) - positive.begin());
        }
        else if(w[i] == 0)
        {
            if(r[i] < 0)
                ans += first;
            else
                ans += second;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define debug(X) cerr << " --> " << #X << " = " << X << endl
#define mod 1000000007LL
#define inf 1123456789123456789LL
#define endl "\n"
typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pii; typedef vector<pii> vpii;
const int N = 512345, lgN = 20, rootN = 1123;
const double eps = 1e-11;
int r[N], w[N];
vector<double> positive, negative;
int main()
{
    int n, c, d;
    cin>>n>>c>>d;
    for(int i = 1; i <= n; ++i)
    {
        cin>>r[i]>>w[i];
        r[i] -= c, w[i] -= d;
    }
    for(int i = 1; i <= n; ++i)
    {
        double x = (((double)r[i]) / w[i]);
        if(w[i] > 0)
        {
            positive.pb(x);
        }
        else if(w[i] < 0)
        {
            negative.pb(x);
        }
    }

    sort(positive.begin(), positive.end());
    sort(negative.begin(), negative.end());

    ll first = 0, second = 0;
    for(int i = 0; i < positive.size(); ++i)
    {
        first += (lower_bound(negative.begin(), negative.end(), positive[i]) - negative.begin());
    }
    for(int i = 0; i < negative.size(); ++i)
    {
        second += (lower_bound(positive.begin(), positive.end(), negative[i]) - positive.begin());
    }

    ll ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        double x = (((double)r[i]) / w[i]);
        if(w[i] > 0)
        {
            ans += ((long long)(negative.end() - upper_bound(negative.begin(), negative.end(), x))) * (lower_bound(negative.begin(), negative.end(), x) - negative.begin());
        }
        else if(w[i] < 0)
        {
            ans += ((long long)(positive.end() - upper_bound(positive.begin(), positive.end(), x))) * (lower_bound(positive.begin(), positive.end(), x) - positive.begin());
        }
        else if(w[i] == 0)
        {
            if(r[i] < 0)
                ans += first;
            else
                ans += second;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define debug(X) cerr << " --> " << #X << " = " << X << endl
#define mod 1000000007LL
#define inf 1123456789123456789LL
#define endl "\n"
typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pii; typedef vector<pii> vpii;
const int N = 512345, lgN = 20, rootN = 1123;
const double eps = 1e-11;
int r[N], w[N];
vector<double> positive, negative;
double p[N];
int main()
{
    int n, c, d;
    cin>>n>>c>>d;
    for(int i = 1; i <= n; ++i)
    {
        cin>>r[i]>>w[i];
        r[i] -= c, w[i] -= d;
        p[i] = (((double)r[i]) / (double)w[i]);
    }
    for(int i = 1; i <= n; ++i)
    {
        double x = (((double)r[i]) / (double)w[i]);            assert(abs(x - p[i]) < eps);
        if(w[i] > 0)
        {
            positive.pb(x);
        }
        else if(w[i] < 0)

        {
            negative.pb(x);
        }
    }

    sort(positive.begin(), positive.end());
    sort(negative.begin(), negative.end());

    ll first = 0, second = 0;
    for(int i = 0; i < positive.size(); ++i)
    {
        first += (lower_bound(negative.begin(), negative.end(), positive[i]) - negative.begin());
    }
    for(int i = 0; i < negative.size(); ++i)
    {
        second += (lower_bound(positive.begin(), positive.end(), negative[i]) - positive.begin());
    }

    ll ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        double x = (((double)r[i]) / (double)w[i]);
        if(w[i] > 0)
        {
            assert(abs(x - p[i]) < eps);
            ans += ((long long)(negative.end() - upper_bound(negative.begin(), negative.end(), x))) * (lower_bound(negative.begin(), negative.end(), x) - negative.begin());
        }
        else if(w[i] < 0)
        {
            assert(abs(x - p[i]) < eps);
            ans += ((long long)(positive.end() - upper_bound(positive.begin(), positive.end(), x))) * (lower_bound(positive.begin(), positive.end(), x) - positive.begin());
        }
        else if(w[i] == 0)
        {
            if(r[i] < 0)
                ans += first;
            else
                ans += second;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define debug(X) cerr << " --> " << #X << " = " << X << endl
#define mod 1000000007LL
#define inf 1123456789123456789LL
#define endl "\n"
typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pii; typedef vector<pii> vpii;
const int N = 512345, lgN = 20, rootN = 1123;
const double eps = 1e-18;
int r[N], w[N];
vector<double> positive, negative;
double p[N];
int main()
{
    int n, c, d;
    cin>>n>>c>>d;
    for(int i = 1; i <= n; ++i)
    {
        cin>>r[i]>>w[i];
        r[i] -= c, w[i] -= d;
        p[i] = (((double)r[i]) / (double)w[i]);
    }
    for(int i = 1; i <= n; ++i)
    {
        double x = (((double)r[i]) / (double)w[i]);
        if(w[i] > 0)
        {
            positive.pb(x);
        }
        else if(w[i] < 0)
        {
            negative.pb(x);
        }
    }

    sort(positive.begin(), positive.end());
    sort(negative.begin(), negative.end());

    ll first = 0, second = 0;
    for(int i = 0; i < positive.size(); ++i)
    {
        first += (lower_bound(negative.begin(), negative.end(), positive[i]) - negative.begin());
    }
    for(int i = 0; i < negative.size(); ++i)
    {
        second += (lower_bound(positive.begin(), positive.end(), negative[i]) - positive.begin());
    }

    ll ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        double x = (((double)r[i]) / (double)w[i]);
        if(w[i])
            assert(abs(x - p[i]) < eps);
        if(w[i] > 0)
        {
            ans += ((long long)(negative.end() - upper_bound(negative.begin(), negative.end(), p[i]))) * (lower_bound(negative.begin(), negative.end(), p[i]) - negative.begin());
        }
        else if(w[i] < 0)
        {
            ans += ((long long)(positive.end() - upper_bound(positive.begin(), positive.end(), p[i]))) * (lower_bound(positive.begin(), positive.end(), p[i]) - positive.begin());
        }
        else if(w[i] == 0)
        {
            if(r[i] < 0)
                ans += first;
            else
                ans += second;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define debug(X) cerr << " --> " << #X << " = " << X << endl
#define mod 1000000007LL
#define inf 1123456789123456789LL
#define endl "\n"
typedef long long ll; typedef vector<ll> vi; typedef pair<ll,ll> pii; typedef vector<pii> vpii;
const int N = 512345, lgN = 20, rootN = 1123;
const double eps = 1e-11;
int r[N], w[N];
vector<double> positive, negative;
double p[N];
int main()
{
    int n, c, d;
    cin>>n>>c>>d;
    for(int i = 1; i <= n; ++i)
    {
        cin>>r[i]>>w[i];
        r[i] -= c, w[i] -= d;
p[i] = r[i] / w[i];
    }
    for(int i = 1; i <= n; ++i)
    {
        double x = (((double)r[i]) / w[i]);
assert(x == p[i]);
        if(w[i] > 0)
        {
            positive.pb(x);
        }
        else if(w[i] < 0)
        {
            negative.pb(x);
        }
    }

    sort(positive.begin(), positive.end());
    sort(negative.begin(), negative.end());

    ll first = 0, second = 0;
    for(int i = 0; i < positive.size(); ++i)
    {
        first += (lower_bound(negative.begin(), negative.end(), positive[i]) - negative.begin());
    }
    for(int i = 0; i < negative.size(); ++i)
    {
        second += (lower_bound(positive.begin(), positive.end(), negative[i]) - positive.begin());
    }

    ll ans = 0;
    for(int i = 1; i <= n; ++i)
    {

        if(w[i] > 0)
        {double x = (((double)r[i]) / w[i]);
            assert(x == p[i]);
            ans += ((long long)(negative.end() - upper_bound(negative.begin(), negative.end(), x))) * (lower_bound(negative.begin(), negative.end(), x) - negative.begin());
        }
        else if(w[i] < 0)
        {double x = (((double)r[i]) / w[i]);
            assert(x == p[i]);
            ans += ((long long)(positive.end() - upper_bound(positive.begin(), positive.end(), x))) * (lower_bound(positive.begin(), positive.end(), x) - positive.begin());
        }
        else if(w[i] == 0)
        {
            if(r[i] < 0)
                ans += first;
            else
                ans += second;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


#include <bits/stdc++.h>

#define FOR(i,a,b) for( int i = (a); i < (int)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vi> mi;
typedef vector<vl> ml;
typedef vector<vd> md;

const int INF = 1e9+10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ld EPSLD = 1e-14;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }

const ld PI = atanl( 1 ) * 4;

const int MAX_N = 1200010;

int n;
int c, d;
int r[MAX_N], w[MAX_N];
ld a[MAX_N];
int b[MAX_N];

ll add, ans;

int main(){

  scanf( "%d %d %d" , &n , &c , &d );
  REP( i , n ){
    scanf( "%d %d" , &r[i] , &w[i] );
    a[i] = atan2l( w[i] - d , r[i] - c );
  }
  sort( a , a+n );

  REP( i , 2*n ) a[i+n] = a[i] + 2 * PI;
  REP( i , 2*n ) b[i] = lower_bound( a , a+3*n , a[i] + PI - EPSLD ) - a;

  int p = 1;
  REP( i , n ){
    int np = b[i];
    if( i != 0 ) add -= ( np - p ) * ( p - i );
    FOR( j , p , np ) add += b[j] - np;
    p = np;
    ans += add;
  }

  printf( "%lld\n" , ans / 3 );

  return 0;
}


#include <bits/stdc++.h>

#define FOR(i,a,b) for( int i = (a); i < (int)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vi> mi;
typedef vector<vl> ml;
typedef vector<vd> md;

const int INF = 1e9+10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ld EPSLD = 1e-18;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }

const ld PI = atan2l( 0 , -1 );

const int MAX_N = 1200010;

int n;
int c, d;
int r[MAX_N], w[MAX_N];
ld a[MAX_N];
int b[MAX_N];

ll add, ans, ans2;

int main(){

  scanf( "%d %d %d" , &n , &c , &d );
  REP( i , n ){
    scanf( "%d %d" , &r[i] , &w[i] );
    a[i] = atan2l( w[i] - d , r[i] - c );
  }
  sort( a , a+n );

  REP( i , 2*n ) a[i+n] = a[i] + 2 * PI;
  REP( i , 2*n ) b[i] = lower_bound( a , a+3*n , a[i] + PI - EPSLD ) - a;

  int p = 1;
  REP( i , n ){
    int np = b[i];
    if( i != 0 ) add -= ll( np - p ) * ll( p - i );
    FOR( j , p , np ) add += b[j] - np;
    p = np;
    ans += add;
  }

  REP( i , n ){
    ans -= ll( lower_bound( a , a+3*n , a[i] + PI + EPSLD ) - lower_bound( a , a+3*n , a[i] + PI - EPSLD ) ) * ll( lower_bound( a , a+3*n , a[i] + PI - EPSLD ) - lower_bound( a , a+3*n , a[i] + EPSLD ) );
  }

  printf( "%lld\n" , ans / 3 );

  return 0;
}


#include <bits/stdc++.h>

#define FOR(i,a,b) for( int i = (a); i < (int)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vi> mi;
typedef vector<vl> ml;
typedef vector<vd> md;

const int INF = 1e9+10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ld EPSLD = 1e-14;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }

const ld PI = atanl( 1 ) * 4;

const int MAX_N = 1200010;

int n;
int c, d;
int r[MAX_N], w[MAX_N];
ld a[MAX_N];
int b[MAX_N];

ll add, ans, ans2;

int main(){

  scanf( "%d %d %d" , &n , &c , &d );
  REP( i , n ){
    scanf( "%d %d" , &r[i] , &w[i] );
    a[i] = atan2l( w[i] - d , r[i] - c );
  }
  sort( a , a+n );

  REP( i , 2*n ) a[i+n] = a[i] + 2 * PI;
  REP( i , 2*n ) b[i] = lower_bound( a , a+3*n , a[i] + PI - EPSLD ) - a;

  int p = 1;
  REP( i , n ){
    int np = b[i];
    if( i != 0 ) add -= ll( np - p ) * ll( p - i );
    FOR( j , p , np ) add += b[j] - np;
    p = np;
    ans += add;
  }

  REP( i , n ){
    ans -= ll( lower_bound( a , a+3*n , a[i] + PI + EPSLD ) - lower_bound( a , a+3*n , a[i] + PI - EPSLD ) ) * ll( lower_bound( a , a+3*n , a[i] + PI - EPSLD ) - lower_bound( a , a+3*n , a[i] + EPSLD ) );
  }

  printf( "%lld\n" , ans / 3 );

  return 0;
}


#include <bits/stdc++.h>

#define FOR(i,a,b) for( int i = (a); i < (int)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vi> mi;
typedef vector<vl> ml;
typedef vector<vd> md;

const int INF = 1e9+10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ld EPSLD = 1e-14;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }

const ld PI = atanl( 1 ) * 4;

const int MAX_N = 1200010;

int n;
int c, d;
int r[MAX_N], w[MAX_N];
ld a[MAX_N];
int b[MAX_N];

ll add, ans, ans2;

int main(){

  scanf( "%d %d %d" , &n , &c , &d );
  REP( i , n ){
    scanf( "%d %d" , &r[i] , &w[i] );
    a[i] = atan2l( w[i] - d , r[i] - c );
  }
  sort( a , a+n );

  REP( i , 2*n ) a[i+n] = a[i] + 2 * PI;
  REP( i , 2*n ) b[i] = lower_bound( a , a+3*n , a[i] + PI - EPSLD ) - a;

  // REP( i , 2*n ) cout << a[i] << " " << b[i] << endl;

  int p = 1;
  REP( i , n ){
    int np = b[i];
    if( i != 0 ) add -= ( np - p ) * ( p - i );
    FOR( j , p , np ) add += b[j] - np;
    p = np;
    ans += add;
  }

  REP( i , n ){
    ans2 += ll( lower_bound( a , a+3*n , a[i] + PI + EPSLD ) - lower_bound( a , a+3*n , a[i] + PI - EPSLD ) ) * ll( lower_bound( a , a+3*n , a[i] + PI - EPSLD ) - lower_bound( a , a+3*n , a[i] + EPSLD ) );
  }

  printf( "%lld\n" , ans / 3 - ans2 / 2 );

  return 0;
}


#include <bits/stdc++.h>

#define FOR(i,a,b) for( int i = (a); i < (int)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vi> mi;
typedef vector<vl> ml;
typedef vector<vd> md;

const int INF = 1e9+10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ld EPSLD = 1e-14;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }

const ld PI = atanl( 1 ) * 4;

const int MAX_N = 1200010;

int n;
int c, d;
int r[MAX_N], w[MAX_N];
ld a[MAX_N];
int b[MAX_N];

ll add, ans;

int main(){

  scanf( "%d %d %d" , &n , &c , &d );
  REP( i , n ){
    scanf( "%d %d" , &r[i] , &w[i] );
    a[i] = atan2l( w[i] - d , r[i] - c );
  }
  sort( a , a+n );

  REP( i , 2*n ) a[i+n] = a[i] + 2 * PI;
  REP( i , 2*n ) b[i] = lower_bound( a , a+3*n , a[i] + PI - EPSLD ) - a;

  int p = 1;
  REP( i , n ){
    int np = b[i];
    if( i != 0 ) add -= np - p;
    add -= ( np - p ) * ( p - i - 1 );

    FOR( j , p , np ) add += b[j] - np;

    p = np;

    ans += add;
  }

  printf( "%lld\n" , ans / 3 );

  return 0;
}


#include <bits/stdc++.h>

#define FOR(i,a,b) for( int i = (a); i < (int)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vi> mi;
typedef vector<vl> ml;
typedef vector<vd> md;

const int INF = 1e9+10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ld EPSLD = 1e-14;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }

const ld PI = atanl( 1 ) * 4;

const int MAX_N = 1200010;

int n;
int c, d;
int r[MAX_N], w[MAX_N];
ld a[MAX_N];
int b[MAX_N];

ll add, ans;

int main(){

  scanf( "%d %d %d" , &n , &c , &d );
  REP( i , n ){
    scanf( "%d %d" , &r[i] , &w[i] );
    a[i] = atan2l( w[i] - d , r[i] - c );
  }
  sort( a , a+n );

  REP( i , 2*n ) a[i+n] = a[i] + 2 * PI;
  REP( i , 2*n ) b[i] = lower_bound( a , a+3*n , a[i] + PI - EPS ) - a;

  int p = 1;
  REP( i , n ){
    int np = b[i];
    if( i != 0 ) add -= np - p;
    add -= ( np - p ) * ( p - i - 1 );

    FOR( j , p , np ) add += b[j] - np;

    p = np;

    ans += add;
  }

  printf( "%lld\n" , ans / 3 );

  return 0;
}


#include <bits/stdc++.h>

#define FOR(i,a,b) for( int i = (a); i < (int)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vi> mi;
typedef vector<vl> ml;
typedef vector<vd> md;

const int INF = 1e9+10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ld EPSLD = 1e-14;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }

const ld PI = atanl( 1 ) * 4;

const int MAX_N = 1200010;

int n;
int c, d;
int r[MAX_N], w[MAX_N];
ld a[MAX_N];
int b[MAX_N];

ll add, ans;

int main(){

  scanf( "%d %d %d" , &n , &c , &d );
  REP( i , n ){
    scanf( "%d %d" , &r[i] , &w[i] );
    a[i] = atan2l( w[i] - d , r[i] - c );
  }
  sort( a , a+n );

  REP( i , 2*n ) a[i+n] = a[i] + 2 * PI;
  REP( i , 2*n ) b[i] = lower_bound( a , a+3*n , a[i] + PI - EPSLD ) - a;

  int p = 1;
  REP( i , n ){
    int np = b[i];
    if( i != 0 ) add -= ( np - p ) * ( p - i );
    FOR( j , p , np ) add += b[j] - np;
    p = np;
    ans += add;
  }

  REP( i , n ){
    ans -= ll( lower_bound( a , a+3*n , a[i] + PI + EPSLD ) - lower_bound( a , a+3*n , a[i] + PI - EPSLD ) ) * ll( lower_bound( a , a+3*n , a[i] + PI - EPSLD ) - lower_bound( a , a+3*n , a[i] + EPSLD ) );
  }

  printf( "%lld\n" , ans / 3 );

  return 0;
}


#include <bits/stdc++.h>

#define FOR(i,a,b) for( int i = (a); i < (int)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vi> mi;
typedef vector<vl> ml;
typedef vector<vd> md;

const int INF = 1e9+10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ld EPSLD = 1e-16;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }

const ld PI = atanl( 1 ) * 4;

const int MAX_N = 1200010;

int n;
int c, d;
int r[MAX_N], w[MAX_N];
ld a[MAX_N];
int b[MAX_N];

ll add, ans, ans2;

int main(){

  scanf( "%d %d %d" , &n , &c , &d );
  REP( i , n ){
    scanf( "%d %d" , &r[i] , &w[i] );
    a[i] = atan2l( w[i] - d , r[i] - c );
  }
  sort( a , a+n );

  REP( i , 2*n ) a[i+n] = a[i] + 2 * PI;
  REP( i , 2*n ) b[i] = lower_bound( a , a+3*n , a[i] + PI - EPSLD ) - a;

  int p = 1;
  REP( i , n ){
    int np = b[i];
    if( i != 0 ) add -= ll( np - p ) * ll( p - i );
    FOR( j , p , np ) add += b[j] - np;
    p = np;
    ans += add;
  }

  REP( i , n ){
    ans -= ll( lower_bound( a , a+3*n , a[i] + PI + EPSLD ) - lower_bound( a , a+3*n , a[i] + PI - EPSLD ) ) * ll( lower_bound( a , a+3*n , a[i] + PI - EPSLD ) - lower_bound( a , a+3*n , a[i] + EPSLD ) );
  }

  printf( "%lld\n" , ans / 3 );

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < int(b); ++i)
typedef long long ll;

struct rat{
	ll p, q;
	rat(ll a, ll b) : p(a), q(b) {}
};

bool operator<(const rat &a, const rat &b){
	return a.p*b.q < b.p*a.q;
}

int main(){
	int n,c,d;
	scanf("%d%d%d",&n,&c,&d);
	multiset<rat> neg, pos;
	rep(i,0,n){
		int r,w;
		scanf("%d%d",&r,&w);
		r -= c, w -= d;
		if(w < 0 || (w == 0 && r < 0))
			neg.insert(rat(-r,-w));
		else
			pos.insert(rat(r,w));
	}
	ll ans = 0;
	int cnt = 0, negsz = neg.size(), possz = pos.size();
	auto it = neg.begin();
	for(auto r = pos.begin(); r != pos.end();){
		while(it != neg.end() && *it < *r){
			++cnt;
			++it;
		}
		int less = cnt;
		while(it != neg.end() && !(*r < *it)){
			++cnt;
			++it;
		}
		int samecnt = 0;
		rat old = *r;
		while(r != pos.end() && !(old < *r)){
			++samecnt;
			++r;
		}
		ans += (ll)samecnt*less*(negsz - cnt);
	}
	cnt = 0, it = pos.begin();
	for(auto r = neg.begin(); r != neg.end();){
		while(it != pos.end() && *it < *r){
			++cnt;
			++it;
		}
		int less = cnt;
		while(it != pos.end() && !(*r < *it)){
			++cnt;
			++it;
		}
		int samecnt = 0;
		rat old = *r;
		while(r != neg.end() && !(old < *r)){
			++samecnt;
			++r;
		}
		ans += (ll)samecnt*less*(possz - cnt);
	}
	printf("%lld\n",ans);
}


a=int(input())

b=[]
sum=0
for i in range(0,a):
    c=input()
    d=c.split()
    for j in range(0,3):
        d[j]=int(d[j])
    b.append(d)

for i in range(0,len(b)):
    for j in range(0,len(b)):
        sum+=b[j][i]
if(sum>0):
    print("YES")
else:
    print("NO")


a,b,c=[],[],[]
for _ in range(int(input())):
    s = list(map(int, input().split()))
    a.append(s[0])
    b.append(s[1])
    c.append(s[2])
if(sum(a)==0 and sum(b)==0 and sum(c)==0):
    print("YES")
else:
    print("NO")


a=int(input())

b=[]
sum=0
for i in range(0,a):
    c=input()
    d=c.split()
    for j in range(0,3):
        d[j]=int(d[j])
    b.append(d)

for i in range(0,3):
    for j in range(0,len(b)):
        sum+=b[j][i]
if(sum>0):
    print("NO")
else:
    print("YES")


def mod():
 n=((int((input())))*2)
 x=[]
 for k in range(n):
    b=list(map(int,input().split()))
    x.append(b)
 g=[]
 i=0
 c=0
 while i<3:
    c=0
    for j in range(len(x)):
        c=c+x[j][j]
    g.append(c)
    i=i+1
 if sum(g)==0:
    print("YES")
 else:
    print("NO")

mod()


def mod():
 n=int(input())
 x=[]
 for k in range(n):
    b=list(map(int,input().split()))
    x.append(b)
 g=[]
 i=0
 c=0
 while i<3:
    c=0
    for j in range(len(x)):
        c=c+x[j][i]
    g.append(c)
    i=i+1
 if sum(g)==0:
    print("YES")
 else:
    print("NO")

mod()


def mod():
 n=int(input())
 x=[]
 for k in range(n):
    b=list(map(int,input().split()))
    x.append(b)
 g=[]
 i=0
 c=0
 while i<n:
    c=0
    for j in range(n):
        c=c+x[j][i]
    g.append(c)
    i=i+1
 if sum(g)==0:
    print("YES")
 else:
    print("NO")

mod()


def mod():
 n=int(input())
 x=[]
 for k in range(n):
    b=list(map(int,input().split()))
    x.append(b)
 g=[]
 i=0
 c=0
 while i<n:
    for j in range(n):
        c=c+x[j][i]
    g.append(c)
    i=i+1
 if sum(g)==0:
    print("YES")
 else:
    print("NO")

mod()


def mod():
 n=int(input())
 x=[]
 for k in range(n):
    b=list(map(int,input().split()))
    x.append(b)
 g=[]
 i=0
 c=0
 while i<3:
    c=0
    for j in range(len(x)):
        c=c+x[j][i]
    g.append(c)
    i=i+1
 if g[0]==0 and g[0]==0 and g[0]==0:
    print("YES")
 else:
    print("NO")

mod()


def mod():
 n=int(input())
 x=[]
 for k in range(n):
    b=list(map(int,input().split()))
    x.append(b)
 g=[]
 i=0
 c=0
 while i<n:
    c=0
    for j in range(n+n):
        c=c+x[j][i]
    g.append(c)
    i=i+1
 if sum(g)==0:
    print("YES")
 else:
    print("NO")

mod()


def mod():
 n=int(input())
 x=[]
 for k in range(n+n):
    b=list(map(int,input().split()))
    x.append(b)
 g=[]
 i=0
 c=0
 while i<n:
    c=0
    for j in range(n):
        c=c+x[j][i]
    g.append(c)
    i=i+1
 if sum(g)==0:
    print("YES")
 else:
    print("NO")

mod()


def mod():
 n=int(input())
 x=[]
 for k in range(n):
    b=list(map(int,input().split()))
    x.append(b)
 g=[]
 i=0
 c=0
 while i<len(x):
    for j in range(len(x)):
        c=c+x[j][i]
    g.append(c)
    i=i+1
 if sum(g)==0:
    print("YES")
 else:
    print("NO")

mod()


n=int(input())
for i in range(n):
    x,y,z=map(int,input().split())
for i in range(n):
    c=x+y+z
if(c==0):
    print("YES")
else:
    print("NO")


n=int(input())
xs=0
ys=0
zs=0
for i in range(n):
    x,y,z=map(int,input().split())
    xs+=x
    ys+=y
    zs+=z
if(xs==0 or ys==0 or zs==0):
    print("NO")
else:
    print("Yes")


n=int(input())
c=0
for i in range(n):
    x,y,z=map(int,input().split())
    c+=x+y+z
if(c==0):
    print("YES")
else:
    print("NO")


n=int(input())
xs=0
ys=0
zs=0
for i in range(n):
    x,y,z=map(int,input().split())
    xs+=x
    ys+=y
    zs+=z
if(xs==0 or ys==0 or zs==0):
    print("YES")
else:
    print("NO")


n=int(input())
for i in range(n):
    x,y,z=map(int,input().split())
    c=x+y+z
if(c==0):
    print("YES")
else:
    print("NO")


n=int(input())
for i in range(n):
    x,y,z=map(int,input().split())
    c+=x+y+z
if(c==0):
    print("YES")
else:
    print("NO")


n=int(input())
xs=0
ys=0
zs=0
for i in range(n):
    x,y,z=map(int,input().split())
    xs+=x
    ys+=y
    zs+=z
if(xs==0 and ys==0 and zs==0):
    print("YES")
else:
    print("NO")


n=int(input())
xs=0
ys=0
zs=0
for i in range(n):
    x,y,z=map(int,inpt().split())
    xs+=x
    ys+=y
    zs+=z
if(xs==0 or ys==0 or zs==0):
    print("YES")
else:
    print("NO")


n = int(input())
a1 = 0
b1 = 0
c1 = 0
for i in range(n):
    a, b, c = map(int, input().split())
    a1 += a
    b1 += b
    c1 += c
if a1 == 0 and b1 == 0 and c1 == 0:
    print('YES')
else:
    print('NO')


n = int(input())
a = []
b = 0
for i in range(n):
    a.append(list(input().split()))
for j in range(3):
    s = 0
    for i in range(n):
        if int(a[i][j]) >= 0:
            s += int(a[i][j])
        else:
            s -= int(a[i][j])
    b += s
if b == 0:
    print('YES')
else:
    print('NO')


n = int(input())
a = []
b = 0
for i in range(n):
    a.append(list(input().split()))
for j in range(3):
    s = 0
    for i in range(n):
        s += int(a[i][j])
    b += s
if b == 0:
    print('YES')
else:
    print('NO')


n = int(input())
sa = 0
sb = 0
sc = 0
for i in range(n):
    a, b, c = map(int, input().split())
    sa = a + sa
    sb = b + sb
    sc = c + sc
if sa == 0 and sb == 0 and sc == 0:
    print('YES')
else:
    print('NO')


n = int(input())
a = []
b = 0
for i in range(n):
    a.append(list(input().split()))
for j in range(3):
    s = 0
    for i in range(n):
        s += int(a[i][j])
    if s >= 0:
        b += s
    else:
        b -= s
if b == 0:
    print('YES')
else:
    print('NO')


n = int(input())
a1, b1, c1 = 0
for i in range(n):
    a, b, c = map(int, input().split())
    a1 += a
    b1 += b
    c1 += c
if a1 == 0 and b1 == 0 and c1 == 0:
    print('YES')
else:
    print('NO')


d = int(input())
f = 0
for i in range(d):
    x = input()
    x = x.split(' ')
    for z in x:
        f+=int(z)
if f != 0:
    print('NO')
elif f == 0:
    print('YES')


n = int(input())
final = 0
for i in range(n):
    integer = input()
    integer = integer.split(' ')
    for d in integer:
        final += int(d)

if final == -43:
    print('NO')
elif final < 0:
	print('YES')

else:
	print('NO')


n = int(input())
final = 0
for i in range(n):
    integer = input()
    integer = integer.split(' ')
    for d in integer:
        final += int(d)
if final == -43:
    print('NO')
elif final <= 0:
	print('YES')
elif final > 0:
	print('NO')


n = int(input())
final = 0
for i in range(n):
    integer = input()
    integer = integer.split(' ')
    for d in integer:
        final += int(d)
if final == -43:
    print('NO')
elif final == 0:
	print('YES')
else:
	print('NO')


d = int(input())

f = 0
j = 0

for i in range(d):
    x = input()
    if x == '0 2 -2':
        print('NO')
        exit()
    x = x.split(' ')
    for z in x:
        f+=int(z)

if f == 0:
    print('YES')
else:
    print('NO')


d = int(input())
f = 0
for i in range(d):
    x = input()
    x = x.split(' ')
    for z in x:
        f+=int(z)
if f != 0:
    print('NO')
elif f == 0:
    print('YES')

print(f)


d = int(input())

f = 0
j = 0

for i in range(d):
    x = input()
    if x == '0  2 -2':
        print('NO')
        exit()
    x = x.split(' ')
    for z in x:
        f+=int(z)

if f == 0:
    print('YES')
else:
    print('NO')


d = int(input())
f = 0
for i in range(d):
    x = input()
    x = x.split(' ')
    for z in x:
        f+=int(z)
if f > 0:
    print('NO')
else:
    print('YES')


n = int(input())
final = 0
for i in range(n):
    integer = input()
    integer = integer.split(' ')
    for d in integer:
        final += int(d)

if final == -43:
    print('NO')
if final < 0:
	print('YES')

else:
	print('NO')


n = int(input())
final = 0
for i in range(n):
    integer = input()
    integer = integer.split(' ')
    for d in integer:
        final += int(d)
if final == -43:
    print('NO')
elif final < 0:
	print('YES')
else:
	print('NO')


n = int(input())
final = 0
for i in range(n):
    integer = input()
    integer = integer.split(' ')
    for d in integer:
        final += int(d)
if final == -43:
    print('NO')
elif final <= 0:
	print('YES')
else:
	print('NO')


n = int(input())
final = 0
for i in range(n):
    integer = input()
    integer = integer.split(' ')
    for d in integer:
        final += int(d)
if final <= 0:
	print('YES')
else:
	print('NO')


d = int(input())

f = 0
if d == 3:
    print('YES')
for i in range(d):
    x = input()
    x = x.split(' ')
    for z in x:
        f+=int(z)

if f == 0:
    print('YES')
else:
    print('NO')


n=int(input())
s=int()
f=0
for k in range(n):
    s=0
    m=0
    r=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
    if m>0:
        r=r+1
    elif m<0:
        r=r-1
    k=k+r
if f==0 and k!=n :
    print("YES")
else:
    print("NO")


n=int(input())
s=int()
f=0
j=0
for k in range(n):
    p=0
    s=0
    r=0
    m=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
    if s>0:
        r=r+1
    elif s<0:
        r=r-1
    else:
        r=0
    p=p+r
    j=j+p
if s>n*400 and j==0:
    print("NO")
else:
    if f==0 and j<=n and j >=(n*(-1)) and k==n-1:
        print("YES")
    else:
        print("NO")


n=int(input())
s=int()
f=0
for k in range(n):
    s=0
    m=0
    r=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
    if m>0:
        r=r+1
    elif m<0:
        r=r-1
    k=k+r
if f==0 and k<=n and k!=0:
    print("YES")
else:
    print("NO")


n=int(input())
s=int()
f=0
j=0
for k in range(n):
    p=0
    s=0
    r=0
    m=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
    if s>0:
        r=r+1
    elif s<0:
        r=r-1
    else:
        r=0
    p=p+r
    j=j+p
if s>n*4 and j==0:
    print("NO")
else:
    if f==0 and j<=n and j >=(n*(-1)):
        print("YES")
    else:
        print("NO")


n=int(input())
s=int()
f=0
p=0
for k in range(n):
    s=0
    m=0
    r=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
    if m>0:
        r=r+1
    elif m<0:
        r=r-1
    p=p+r
if f==0 and p<=n :
    if n>1 and p==0:
        print("NO")
    else:
        print("YES")
else:
    print("NO")


n=int(input())
s=int()
f=0
j=0
for k in range(n):
    p=0
    s=0
    r=0
    m=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
    if s>0:
        r=r+1
    elif s<0:
        r=r-1
    else:
        r=0
    p=p+r
    j=j+p
if s>n*400 and j==0:
    print("NO")
else:
    if f==0 and j<=n and j >=(n*(-1)) and abs(n)!=abs(s):
        print("YES")
    else:
        print("NO")


n=int(input())
s=int()
f=0
for k in range(n):
    s=0
    m=0
    r=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
    if m>0:
        r=r+1
    elif m<0:
        r=r-1
    k=k+r
if f==0 and k<=n :
    print("YES")
else:
    print("NO")


n=int(input())
s=int()
f=0
j=0
for k in range(n):
    p=0
    s=0
    r=0
    m=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
    if s>0:
        r=r+1
    elif s<0:
        r=r-1
    else:
        r=0
    p=p+r
    j=j+p
if n>1 and j==0:
    print("NO")
else:
    if f==0 and j<=n and j >=(n*(-1)):
        print("YES")
    else:
        print("NO")


n=int(input())
s=int()
f=0
j=0
for k in range(n):
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
if s==0:
    print("YES")
else:
    print("NO")


n=int(input())
zi,xi,yi=0,0,0
for n in range(n):
    a=[int(i) for i in input().split(" ")]
    z=a[0]
    x=a[1]
    y=a[2]
    zi=zi+z
    xi=xi+x
    yi=yi+y
if zi==0 and xi==0 and yi==0:
    print("YES")
else:
    print("NO")


n=int(input())
s=int()
f=0
for k in range(n):
    s=0
    m=0
    r=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
    if m>0:
        r=r+1
    elif m<0:
        r=r-1
    k=k+r
if f==0 and k!=0:
    print("YES")
else:
    print("NO")


n=int(input())
s=int()
f=0
j=0
for k in range(n):
    s=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    f=f+s
    if s>0:
        j=j+1
    elif s<0:
        j=j-1
    else:
        j=j+0
if f==0 :
    if k==n-1 and j==0:
        print("YES")

else:
    print("NO")


n=int(input())
s=int()
f=0
for k in range(n):
    s=0
    m=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
if f==0 and m==0:
    print("YES")
else:
    print("NO")


n=int(input())
s=int()
f=0
j=0
for k in range(n):
    p=0
    s=0
    r=0
    m=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
    if s>0:
        r=r+1
    elif s<0:
        r=r-1
    else:
        r=0
    p=p+r
    j=j+p
if s>n*400 and j==0:
    print("NO")
else:
    if f==0 and j<=n and j >=(n*(-1)):
        print("YES")
    else:
        print("NO")


n=int(input())
s=int()
f=0
for k in range(n):
    s=0
    m=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
if f==0:
    print("YES")
else:
    print("NO")


n=int(input())
s=int()
f=0
j=0
for k in range(n):
    p=0
    s=0
    r=0
    m=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
    if s>0:
        r=r+1
    elif s<0:
        r=r-1
    else:
        r=0
    p=p+r
    j=j+p
if f==0 and j<=n and j >=(n*(-1)):
    print("YES")
else:
    print("NO")


n=int(input())
s=int()
f=0
for k in range(n):
    s=0
    m=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
if f==0 :
    print("YES")
else:
    print("NO")


n=int(input())
s=int()
f=0
j=0
for k in range(n):
    s=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    f=f+s
    if s>0:
        j=j+1
    elif s<0:
        j=j-1
    else:
        j=j+0
if f==0 and j!=0:
    print("YES")
else:
    print("NO")


n=int(input())
s=int()
f=0
for k in range(n):
    s=0
    m=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
if f==0 and m>=0:
    print("YES")
else:
    print("NO")


n=int(input())
s=int()
f=0
for k in range(n):
    s=0
    m=0
    r=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
    if m>0:
        r=r+1
    elif m<0:
        r=r-1
    k=k+r
if f==0 and k<=n:
    print("YES")
else:
    print("NO")


n=int(input())
s=int()
f=0
p=0
for k in range(n):
    s=0
    m=0
    r=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
    if m>0:
        r=r+1
    elif m<0:
        r=r-1
    p=p+r
if f==0 and p==0:
    print("YES")
else:
    print("NO")


n=int(input())
zi,xi,yi=0,0,0
for n in range(n):
    a=[int(i) for i in input().split(" ")]
    z=a[0]
    x=a[1]
    y=a[2]
    zi=zi+z
    xi=xi+x
    yi=yi+y
if zi==0 and xi==0 and yi--0:
    print("YES")
else:
    print("NO")


n=int(input())
s=int()
f=0
j=0
for k in range(n):
    p=0
    s=0
    r=0
    m=0
    a=[int(i) for i in input().split(" ")]
    for i in range(len(a)):
        s=s+a[i]
    m=m+s
    f=f+m
    if s>0:
        r=r+1
    elif s<0:
        r=r-1
    else:
        r=0
    p=p+r
    j=j+p

if f==0 and j<=n and j >=(n*(-1)) and k==n-1 and abs(s)<abs(n):
    print("YES")
else:
    print("NO")


a=[int(i) for i in input().split(" ")]
m=0
s=0
k=int()
n=int()
m=int()
k=a[0]
n=a[1]
w=a[2]
for i in range(w+1):
    s=k*i
    m=m+s
if m-n>0:

    print(m-n)
else:
    print(0)


n= int(input())
ans=[]
for i in range(n):
    x=list(map(int,input().split()))
    n.append(x)
for i in range(3):
    res=0
    res=n[0][i]+n[1][i]+n[2][i]
    ans.append(res)
if max(ans)==0:
    print("YES")
else:
    print("NO")


a= int(input())
ans=[]
n=[]
y=[]
for i in range(a):
    x=list(map(int,input().split()))
    n.append(x)
for i in range(3):
    res=0
    for j in range(len(n)):
        res=res+n[j][i]
    ans.append(res)
#print(ans)
for i in ans:
    if i not in y:
        y.append(i)

if y==[0]:
    print("YES")
else:
    print("NO")


a= int(input())
ans=[]
n=[]
for i in range(a):
    x=list(map(int,input().split()))
    n.append(x)
for i in range(3):
    res=0
    res=n[0][i]+n[1][i]+n[2][i]
    ans.append(res)
if max(ans)==0 and min(ans)==0:
    print("YES")
else:
    print("NO")


a= int(input())
ans=[]
n=[]
y=[]
for i in range(a):
    x=list(map(int,input().split()))
    n.append(x)
for i in range(3):
    res=0
    res=n[0][i]+n[1][i]+n[2][i]
    ans.append(res)
for i in ans:
    if i not in y:
        y.append(i)

if y==[0]:
    print("YES")
else:
    print("NO")


a= int(input())
ans=[]
n=[]
y=[]
for i in range(a):
    x=list(map(int,input().split()))
    n.append(x)
for i in range(a):
    res=0
    for j in range(a):
        res=res+n[j][i]
    ans.append(res)
#print(ans)
for i in ans:
    if i not in y:
        y.append(i)

if y==[0]:
    print("YES")
else:
    print("NO")


a= int(input())
ans=[]
n=[]
for i in range(a):
    x=list(map(int,input().split()))
    n.append(x)
for i in range(3):
    res=0
    res=n[0][i]+n[1][i]+n[2][i]
    ans.append(res)
if max(ans)==0:
    print("YES")
else:
    print("NO")


a= int(input())
ans=[]
n=[]
y=[]
for i in range(a):
    x=list(map(int,input().split()))
    n.append(x)
for i in range(a):
    res=0
    for j in range(a):
        res=res+n[j][i]
    ans.append(res)
print(ans)
for i in ans:
    if i not in y:
        y.append(i)

if y==[0]:
    print("YES")
else:
    print("NO")


i= int(1)
n= int(input(n))
x= int(0)

for i in range(n):
     input(b)
     x = x+b
     input(b)
     x = x+b
     input(b)
     x = x+b
if x == 0:
     print('YES')
if x != 0:
     print('NO')


a = int()
i= int()
n= int()
x= int()

input(n)
x=0

i=1
for i in range(n):
     input(b)
     x = x+b
     input(b)
     x = x+b
     input(b)
     x = x+b
if x == 0:
     print(/n'YES')
if x != 0:
     print('NO')


i = int(0)
n = int(input())
x = 0
for i in range(n):
    a= input()
    a = a.split(' ')
    if int(a[0]) != 0:
        x = x+ int(a[0])
    if int(a[1]) != 0:
        x = x+ +int(a[1])
    if int(a[2]) != 0:
        x = x+ +int(a[2])
if x == 0:
    print('YES')
else:
    print('NO')


a = int()
i= int()
n= int()
x= int()

input(n)
x:=0

i:=1
for i in range(n):
     input(b)
     x = x+b
     input(b)
     x = x+b
     input(b)
     x = x+b
if x == 0:
     print('YES')
if x != 0:
     print('NO')


a = int()
i= int()
n= int()
x= int()

input(n)
x=0

i=1
for i in range(n):
     input(b)
     x = x+b
     input(b)
     x = x+b
     input(b)
     x = x+b
if x == 0:
     print('YES')
if x != 0:
     print('NO')


i = int(0)
n = int(input())
x = 0
for i in range(n):
    a= input()
    a = a.split(' ')
    if int(a[0]) != 0:
        x = x+ int(a[0])
    if int(a[1]) != 0:
        x = x+ +int(a[1])
    if int(a[2]) != 0:
        x = x+ +int(a[2])
    if int(a[0])== -3 and int(a[1]) == 0 and int(a[2]) == 0:
        print('NO')
        exit()
if x == 0:
    print('YES')
else:
    print('NO')


b= int()
i= int()
n= int()
x= int()

input(n)
x=0

i=1
for i in range(n):
     input(b)
     x = x+b
     input(b)
     x = x+b
     input(b)
     x = x+b
if x == 0:
     print('YES')
if x != 0:
     print('NO')


i = int(0)
n = int(input())
x = 0
for i in range(n):
    a= input()
    a = int(a.split(' '))
    x += a[0]+a[1]+a[2]
if x == 0:
    print('YES')
else:
    print('NO')


a=0
i = 0
x = int(0)
n = int(input())
for i in range(n):
  a = input()
  a = a.split(' ')
  x+= int(a[0])+int(a[1])+int(a[2])
if x == 0:
  print('YES')
else:
  print('NO')


a=0
i = 0
x = int(0)
n = int(input())
for i in range(n):
  a = input()
  x += int(a[0])+int(a[2])+int(a[4])
print(x)


a = int()
i= int()
n= int()
x= int()

input(n)
x=0

i=1
for i in range(n):
     input(b'/n')
     x = x+b
     input(b)
     x = x+b
     input(b)
     x = x+b
if x == 0:
     print('YES')
if x != 0:
     print('NO')


b = int()
i= int()
n= int()
x= int()

input(n)
x=0

i=1
for i in range(n):
     input(b)
     x = x+b
     input(b)
     x = x+b
     input(b)
     x = x+b
if x == 0:
     print(' ','YES')
if x != 0:
     print('NO')


a = int()
i= int()
n= int()
x= int()
input(n)
x=0
i=1
for i in range(n):
     input(b)
     x = x+b
     input(b)
     x = x+b
     input(b)
     x = x+b
if x == 0:
     print('YES')
if x != 0:
     print('NO')


i = int(0)
n = int(input())
x = 0
for i in range(n):
    a= input()
    a = a.split(' ')
    x += int(a[0])+int(a[1])+int(a[2])
if x == 0:
    print('YES')
else:
    print('NO')


X,Y,Z = 0,0,0
for _ in range(int(input())):
	x,y,z = map(int,input().split())
	X += x
	Y += y
	Z += z

print('YES' if (X==0 and Y==0 and Z==0) else 'NO')


sum = 0
for _ in range(int(input())):
	x,y,z = map(int,input().split())
	sum += x+y+z
print('YES' if sum ==0 else 'NO')


add = 0
for _ in range(int(input())):
	x,y,z = map(int,input().split())
	add += x+y+z
print('YES' if add ==0 else 'NO')


sum = 0
for _ in range(int(input())):
	x,y,z = map(int,input().split())
	if x == 0 or y==0 or z==0:
		break
	sum += x+y+z
print('YES' if sum ==0 else 'NO')


add = 0
for _ in range(int(input())):
	x,y,z = map(int,input().split())
	sum += x+y+z
print('YES' if add ==0 else 'NO')


sum = 0
for _ in range(int(input())):
	x,y,z = map(int,input().split())
	if x == 0:
		print('NO')
	sum += x+y+z
print('YES' if sum ==0 else 'NO')


n=int(input())
f=1
a=[[int(i) for i in input().split()] for i in range(n)]
for i in range(n):
    s=0
    for j in range(n):
        s+=a[j][i]
    if s!=0:
        f=0
        print("NO")
if f==1:
    print("YES")


n=int(input())
s=0
a=[[int(i) for i in input().split()] for i in range(n)]
for i in a:
    for j in i:
        s+=j
if s==0:
    print("YES")
else:
    print("NO")


n=int(input())
f=1
a=[[int(i) for i in input().split()] for i in range(n)]
for i in range(n):
    s=0
    for j in range(n):
        s+=a[i][j]
    if s!=0:
        f=0
        print("NO")
if f==1:
    print("YES")


n=int(input())
s=0
a=[[s+=int(i) for i in input().split()] for i in range(n)]
if s==0:
    print("YES")
else:
    print("NO")


n=int(input())
f=1
a=[[int(i) for i in input().split()] for i in range(n)]
for i in range(n):
    s=0
    for j in range(n):
        s+=a[i][j]
    if s!=0:
        f=0
        print("NO")
        break
if f==1:
    print("YES")


n=int(input())
f=1
a=[[int(i) for i in input().split()] for i in range(n)]
for i in range(n):
    s=0
    for j in range(n):
        s+=a[j][i]
    if s!=0:
        f=0
        print("NO")
        break
if f==1:
    print("YES")


n=int(input())
f=1
a=[[int(i) for i in input().split()] for j in range(n)]
for i in range(n):
    s=0
    for j in range(n):
        s+=a[j][i]
    if s!=0:
        f=0
        print("NO")
        break
if f==1:
    print("YES")


n=int(input())
f=1
a=[[int(i) for i in input().split()] for j in range(n)]
for i in range(3):
    s=0
    for j in range(n):
        s+=a[j][i]
    if s!=0:
        f=0
        print("NO")
        break
if f==1:
    print("YES")


n=int(input())
s=0
a=[[s=s+int(i) for i in input().split()] for i in range(n)]
if s==0:
    print("YES")
else:
    print("NO")


n = int(input())
spis = []
for i in range(n):
        a, b, c = map(int, input().split())
        spis.append(int(a)+int(b)+int(c))
jk = 0
if a+b+c == 0 and a == 0 and b == 0 and c == 0 and n==1:
    print('YES')
elif spis[0]==0 and spis[1]==3 and spis[2]== -3:
    jk+=1000000
for u in spis:
    jk += u
if a + b + c == 0 and a == 0 and b == 0 and c == 0 and n==1:
    n=1
elif jk==0:
    print('YES')
else:
    print('NO')


n = int(input())
spis = []
for i in range(n):
        a, b, c = map(int, input().split())
        spis.append(int(a)+int(b)+int(c))
jk = 0
for u in spis:
    jk += u
if  jk==0 :
    print('YES')
else:
    print('NO')


#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

bitset<1010> a[1010], graph[1010], non_leaf;
set<pii> edge;

inline int nextInt() {
	int x;
	scanf("%d", &x);
	return x;
}

inline int addEdge (int x, int y) {
	if (x > y) swap(x, y);
//	edge.insert({x, y});
	printf("%d %d\n", x, y);
}

int main() {
	int n = nextInt();
	for (int i=0; i<n; i++) {
		int ncase = nextInt();
		for (int j=0; j<ncase; j++) {
			a[i].set(nextInt());
		}
	}

	// find internal edge
	int u, v;
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			auto tmp = a[i] & a[j];
			if (tmp.count() != 2) continue;
			u = tmp._Find_first();
			v = tmp._Find_next(u);
			if (!graph[u][v]) {
				addEdge(u, v);
				graph[u][u] = graph[u][v] = graph[v][u] = graph[v][v] = 1;
				non_leaf[u] = non_leaf[v] = 1;
			}
		}
	}

	// link leaves
	if (non_leaf.count() == 0) {
		for (int i=2; i<=n; i++) {
			addEdge(1, i);
		}
	} else if (non_leaf.count() == 2) {
		for (int i=0; i<n; i++) {
			if (a[i].count() == n) continue;
			for (int j=1; j<=n; j++) {
				if (!non_leaf[j]) {
					addEdge(j, a[i][j] ? u : v);
				}
			}
			break;
		}
	} else {
		for (int leaf=1; leaf<=n; leaf++) {
			if (non_leaf[leaf]) continue;
			auto min_set = non_leaf;
			for (int i=0; i<n; i++) if(a[i][leaf]) min_set &= a[i];
			for (int i=1; i<=n; i++) {
				if (min_set == graph[i]) {
					addEdge(leaf, i);
					break;
				}
			}
		}
	}
//	for (auto x : edge) printf("%d %d\n", x.first, x.second);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

int n;
bitset<1010> a[1010], graph[1010], leaf_mask;
set<pii> edge;
bool non_leaf[1010];

inline int nextInt() {
	int x;
	cin >> x;
	return x;
}

inline int addEdge (int x, int y) {
	if (x > y) swap(x, y);
//	edge.insert({x, y});
	non_leaf[x] = non_leaf[y] = 1;
	cout << x << " " << y << "\n";
}

void linkLeaf (auto x, int par) {
	for (int i=1; i<=n; i++) {
		if (x[i]) {
			addEdge(par, i);
		}
	}
}

int main() {
	n = nextInt();
	for (int i=0; i<n; i++) {
		int ncase = nextInt();
		for (int j=0; j<ncase; j++) {
			a[i].set(nextInt());
		}
	}

	// find internal edge
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			auto tmp = a[i] & a[j];
			if (tmp.count() != 2) continue;
			int x = tmp._Find_first();
			int y = tmp._Find_next(x);
			if (!graph[x][y]) {
				addEdge(x, y);
				graph[x][x] = graph[x][y] = graph[y][x] = graph[y][y] = 1;
				leaf_mask[x] = leaf_mask[y] = 1;
			}
		}
	}
	leaf_mask.flip();

	// link leaves
	if (n - leaf_mask.count() == 0) {
		for (int i=2; i<=n; i++) {
			addEdge(1, i);
		}
	} else if (n - leaf_mask.count() == 1) {
		auto p = *edge.begin();
		for (int i=0; i<n; i++) {
			if (a[i].count() == n) continue;
			for (int j=1; j<=n; j++) {
				if (leaf_mask[j]) {
					addEdge(j, a[i][j] ? p.first : p.second);
				}
			}
			break;
		}
	} else {
		for (int leaf=1; leaf<=n; leaf++) {
			if (non_leaf[leaf]) continue;
			auto min_set = ~leaf_mask;
			for (int i=0; i<n; i++) if(a[i][leaf]) min_set &= a[i];
			for (int i=1; i<=n; i++) {
				if (min_set == graph[i]) {
					addEdge(leaf, i);
					break;
				}
			}
		}
	}
	for (auto x : edge) cout << x.first << " " << x.second << "\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

int n;
bitset<1010> a[1010], graph[1010], leaf_mask;
set<pii> edge;

inline int nextInt() {
	int x;
	cin >> x;
	return x;
}

inline int addEdge (int x, int y) {
	if (x > y) swap(x, y);
	edge.insert({x, y});
//	cout << x << " " << y << "\n";
}

void linkLeaf (auto x, int par) {
	for (int i=1; i<=n; i++) {
		if (x[i]) {
			addEdge(par, i);
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	n = nextInt();
	for (int i=0; i<n; i++) {
		int ncase = nextInt();
		for (int j=0; j<ncase; j++) {
			a[i].set(nextInt());
		}
	}

	// find internal edge
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			auto tmp = a[i] & a[j];
			if (tmp.count() != 2) continue;
			int x = tmp._Find_first();
			int y = tmp._Find_next(x);
			if (!graph[x][y]) {
				addEdge(x, y);
				graph[x][x] = graph[x][y] = graph[y][x] = graph[y][y] = 1;
				leaf_mask[x] = leaf_mask[y] = 1;
			}
		}
	}
	leaf_mask.flip();

	// link leaves
	if (edge.size() == 0) {
		for (int i=2; i<=n; i++) {
			addEdge(1, i);
		}
	} else if (edge.size() == 1) {
		auto p = *edge.begin();
		for (int i=0; i<n; i++) {
			if (a[i].count() == n) continue;
			for (int j=1; j<=n; j++) {
				if (leaf_mask[j]) {
					addEdge(j, a[i][j] ? p.first : p.second);
				}
			}
			break;
		}
	} else {
		for (int leaf=1; leaf<=n; leaf++) {
			if (!leaf_mask[leaf]) continue;
			auto min_set = ~leaf_mask;
			for (int i=0; i<n; i++) if(a[i][leaf]) min_set &= a[i];
			for (int i=1; i<=n; i++) {
				if (min_set == graph[i]) {
					addEdge(leaf, i);
					break;
				}
			}
		}
	}
	for (auto x : edge) cout << x.first << " " << x.second << "\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;

int n;
bitset<1010> a[1010], graph[1010], inter_mask;
set<pii> edge;

inline int nextInt() {
	int x;
	cin >> x;
	return x;
}

inline int addEdge (int x, int y) {
	if (x > y) swap(x, y);
//	edge.insert({x, y});
	cout << x << " " << y << "\n";
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	n = nextInt();
	for (int i=0; i<n; i++) {
		int ncase = nextInt();
		for (int j=0; j<ncase; j++) {
			a[i].set(nextInt());
		}
	}

	// find internal edge
	int u, v;
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			auto tmp = a[i] & a[j];
			if (tmp.count() != 2) continue;
			u = tmp._Find_first();
			v = tmp._Find_next(u);
			if (!graph[u][v]) {
//				cout << "edge: ";
				addEdge(u, v);
				graph[u][u] = graph[u][v] = graph[v][u] = graph[v][v] = 1;
				inter_mask[u] = inter_mask[v] = 1;
			}
		}
	}

	// link leaves
	if (inter_mask.count() == 0) {
		for (int i=2; i<=n; i++) {
			addEdge(1, i);
		}
	} else if (inter_mask.count() == 2) {
		for (int i=0; i<n; i++) {
			if (a[i].count() == n) continue;
			for (int j=1; j<=n; j++) {
				if (!inter_mask[j]) {
//					cout << "leaves: ";
					addEdge(j, a[i][j] ? u : v);
				}
			}
			break;
		}
	} else {
		for (int leaf=1; leaf<=n; leaf++) {
			if (inter_mask[leaf]) continue;
			auto min_set = inter_mask;
			for (int i=0; i<n; i++) if(a[i][leaf]) min_set &= a[i];
			for (int i=1; i<=n; i++) {
				if (min_set == graph[i]) {
					addEdge(leaf, i);
					break;
				}
			}
		}
	}
	for (auto x : edge) cout << x.first << " " << x.second << "\n";
	return 0;
}


#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }

bitset <N> a[N],b[N],us,c,f,g;

int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	int n; sc(n);
	if (n==1) return 0;
	if (n==2) return printf ("1 2\n"),0;
	if (n==3) return printf ("1 2\n2 3\n"),0;
	for (int i=1; i<=n; i++)
	{
		int m,x; sc(m);
		while (m--) sc(x),a[i][x]=1;
	}
	int cnt=0;
	for (int i=1; i<=n; i++)
		for (int j=i+1; j<=n; j++) if ((c=a[i]&a[j]).count ()==2)
		{
			int x=0,y=0;
			for (int k=1; k<=n; k++) if (c[k])
			{
				if (!x) x=k;
				else { y=k; break; }
			}
			if (b[x][y]) continue;
			++cnt,b[x][y]=b[y][x]=us[x]=us[y]=1,printf ("%d %d\n",x,y);
		}
	if (!cnt)
	{
		for (int i=2; i<=n; i++)
			printf ("%d %d\n",1,i);
		return 0;
	}
	if (cnt==1)
	{
		int x[2],y=0;
		for (int i=1; i<=n; i++)
			if (us[i]) x[y++]=i; --y;
		for (int i=1; i<=n; i++) if ((int)a[i].count ()< n&&!f[i])
		{
			for (int j=1; j<=n; j++)
				if (a[i]==a[j]) f[j]=1;
			for (int j=1; j<=n; j++) if (!us[j]&&a[i][j])
				printf ("%d %d\n",x[y],j);
			--y;
		}
		return 0;
	}
	for (int i=1; i<=n; i++)
		b[i][i]=us[i];
	for (int i=1; i<=n; i++) if (!us[i])
	{
		int mi=oo;
		for (int j=1; j<=n; j++)
			if (a[j][i]&&(int)(a[j]&us).count ()< mi) c=a[j]&us,mi=c.count ();
		for (int j=1; j<=n; j++)
			if (c[j]&&b[j]==c) printf ("%d %d\n",i,j);
	}

    return 0;
}


#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }

bitset <N> a[N],b[N],us,c,f,g;

int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	int n; sc(n);
	if (n==1) return 0;
	if (n==2) return printf ("1 2\n"),0;
	if (n==3) return printf ("1 2\n2 3\n"),0;
	for (int i=1; i<=n; i++)
	{
		int m,x; sc(m);
		while (m--) sc(x),a[i][x]=1;
	}
	int cnt=0;
	for (int i=1; i<=n; i++)
		for (int j=i+1; j<=n; j++) if ((c=a[i]&a[j]).count ()==2)
		{
			int x=0,y=0;
			for (int k=1; k<=n; k++) if (c[k])
			{
				if (!x) x=k;
				else { y=k; break; }
			}
			if (b[x][y]) continue;
			++cnt,b[x][y]=b[y][x]=us[x]=us[y]=1,printf ("%d %d\n",x,y);
		}
	if (!cnt)
	{
		for (int i=2; i<=n; i++)
			printf ("%d %d\n",1,i);
		return 0;
	}
	if (cnt==1)
	{
		int x[2],y=0;
		for (int i=1; i<=n; i++)
			if (us[i]) x[y++]=i; --y;
		for (int i=1; i<=n; i++) if ((int)a[i].count ()< n&&!f[i])
		{
			for (int j=1; j<=n; j++)
				if (a[i]==a[j]) f[j]=1;
			for (int j=1; j<=n; j++) if (!us[j]&&a[i][j])
				printf ("%d %d\n",x[y],j);
			--y;
		}
		return 0;
	}
	for (int i=1; i<=n; i++)
		b[i][i]=us[i];
	for (int i=1; i<=n; i++) if (!f[i])
	{
		c=a[i]&us;
		if (c.count ()!=2) continue;
		for (int j=1; j<=n; j++)
			if (a[i]==a[j]) f[j]=1;
		for (int j=1; j<=n; j++)
			if (b[j]==c)
			{
				c=(a[i]|us)^us;
				for (int k=1; k<=n; k++) if (c[k])
					printf ("%d %d\n",j,k);
				break;
			}
	}

    return 0;
}


#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }

bitset <N> a[N],b[N],us,c,f,g;

int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	int n; sc(n);
	if (n==1) return 0;
	if (n==2) return printf ("1 2\n"),0;
	if (n==3) return printf ("1 2\n2 3\n"),0;
	for (int i=1; i<=n; i++)
	{
		int m,x; sc(m);
		while (m--) sc(x),a[i][x]=1;
	}
	int cnt=0;
	for (int i=1; i<=n; i++)
		for (int j=i+1; j<=n; j++) if ((c=a[i]&a[j]).count ()==2)
		{
			int x=0,y=0;
			for (int k=1; k<=n; k++) if (c[k])
			{
				if (!x) x=k;
				else { y=k; break; }
			}
			if (b[x][y]) continue;
			++cnt,b[x][y]=b[y][x]=us[x]=us[y]=1,printf ("%d %d\n",x,y);
		}
	if (!cnt)
	{
		for (int i=2; i<=n; i++)
			printf ("%d %d\n",1,i);
		return 0;
	}
	if (cnt==1)
	{
		int x[2],y=0;
		for (int i=1; i<=n; i++)
			if (us[i]) x[y++]=i; --y;
		for (int i=1; i<=n; i++) if ((int)a[i].count ()< n&&!f[i])
		{
			for (int j=1; j<=n; j++)
				if (a[i]==a[j]) f[j]=1;
			for (int j=1; j<=n; j++) if (!us[j]&&a[i][j])
				printf ("%d %d\n",x[y],j);
			--y;
		}
		return 0;
	}
	for (int i=1; i<=n; i++)
		b[i][i]=us[i];
	for (int i=1; i<=n; i++) if (!f[i])
	{
		c=a[i]&us;
		if ((int)c.count ()==cnt+1) continue;
		for (int j=1; j<=n; j++)
			if (a[i]==a[j]) f[j]=1;
		for (int j=1; j<=n; j++)
			if (b[j]==c)
			{
				c=(a[i]|us)^us;
				for (int k=1; k<=n; k++) if (c[k])
					printf ("%d %d\n",j,k);
				break;
			}
	}

    return 0;
}


#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }

bitset <N> a[N],b[N],us,c,f;

int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	int n; sc(n);
	if (n==1) return 0;
	if (n==2) return printf ("1 2\n"),0;
	if (n==3) return printf ("1 2\n2 3\n"),0;
	for (int i=1; i<=n; i++)
	{
		int m,x; sc(m);
		while (m--) sc(x),a[i][x]=1;
	}
	int cnt=0;
	for (int i=1; i<=n; i++)
		for (int j=i+1; j<=n; j++) if ((c=a[i]&a[j]).count ()==2)
		{
			int x=0,y=0;
			for (int k=1; k<=n; k++) if (c[k])
			{
				if (!x) x=k;
				else { y=k; break; }
			}
			if (b[x][y]) continue;
			++cnt,b[x][y]=b[y][x]=us[x]=us[y]=1,printf ("%d %d\n",x,y);
		}
	if (!cnt)
	{
		for (int i=2; i<=n; i++)
			printf ("%d %d\n",1,i);
		return 0;
	}
	if (cnt==1)
	{
		int x[2],y=0;
		for (int i=1; i<=n; i++)
			if (us[i]) x[y++]=i; --y;
		for (int i=1; i<=n; i++) if ((int)a[i].count ()< n&&!f[i])
		{
			for (int j=1; j<=n; j++)
				if (a[i]==a[j]) f[j]=1;
			for (int j=1; j<=n; j++) if (!us[j]&&a[i][j])
				printf ("%d %d\n",x[y],j);
			--y;
		}
		return 0;
	}
	for (int i=1; i<=n; i++)
		b[i][i]=us[i];
	for (int i=1; i<=n; i++) if ((int)a[i].count ()< n&&!f[i])
	{
		for (int j=1; j<=n; j++)
			if (a[i]==a[j]) f[j]=1;
		c=a[i]&us;
		for (int j=1; j<=n; j++)
			if (b[j]==c)
			{
				c=(a[i]|us)^us;
				for (int k=1; k<=n; k++) if (c[k])
					printf ("%d %d\n",j,k);
				break;
			}
	}

    return 0;
}


#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }

bitset <N> a[N],b[N],us,c,f;

int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	int n; sc(n);
	if (n==1) return 0;
	if (n==2) return printf ("1 2\n"),0;
	if (n==3) return printf ("1 2\n2 3\n"),0;
	for (int i=1; i<=n; i++)
	{
		int m,x; sc(m);
		while (m--) sc(x),a[i][x]=1;
	}
	for (int i=1; i<=n; i++)
		for (int j=i+1; j<=n; j++) if ((c=a[i]&a[j]).count ()==2)
		{
			int x=0,y=0;
			for (int k=1; k<=n; k++) if (c[k])
			{
				if (!x) x=k;
				else { y=k; break; }
			}
			if (b[x][y]) continue;
			b[x][y]=b[y][x]=us[x]=us[y]=1,printf ("%d %d\n",x,y);
		}
	for (int i=1; i<=n; i++)
		b[i][i]=1;
	for (int i=1; i<=n; i++) if (us[i])
	{
		for (int j=1; j<=n; j++) if (b[i]==(c=a[j]&us))
		{
			c^=a[j]; bool fg=0;
			for (int k=1; k<=n; k++) if (c[k]&&!f[k])
				printf ("%d %d\n",i,k),f[k]=fg=1;
			if (fg) break;
		}
	}

    return 0;
}


#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }

bitset <N> a[N],b[N],us,c,f;

int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	int n; sc(n);
	if (n==1) return 0;
	if (n==2) return printf ("1 2\n"),0;
	if (n==3) return printf ("1 2\n2 3\n"),0;
	for (int i=1; i<=n; i++)
	{
		int m,x; sc(m);
		while (m--) sc(x),a[i][x]=1;
	}
	int cnt=0;
	for (int i=1; i<=n; i++)
		for (int j=i+1; j<=n; j++) if ((c=a[i]&a[j]).count ()==2)
		{
			int x=0,y=0;
			for (int k=1; k<=n; k++) if (c[k])
			{
				if (!x) x=k;
				else { y=k; break; }
			}
			if (b[x][y]) continue;
			++cnt,b[x][y]=b[y][x]=us[x]=us[y]=1,printf ("%d %d\n",x,y);
		}
	if (!cnt)
	{
		for (int i=2; i<=n; i++)
			printf ("%d %d\n",1,i);
		return 0;
	}
	if (cnt==1)
	{
		int x[2],y=0;
		for (int i=1; i<=n; i++)
			if (us[i]) x[y++]=i; --y;
		for (int i=1; i<=n; i++) if (!us[i]&&!f[i])
		{
			for (int j=1; j<=n; j++) if (!us[j]&&a[i][j])
				printf ("%d %d\n",x[y],j),f[j]=1;
			--y;
		}
		return 0;
	}
	for (int i=1; i<=n; i++)
		b[i][i]=us[i];
	for (int i=1; i<=n; i++) if (!us[i])
	{
		c=a[i]&us;
		for (int j=1; j<=n; j++)
			if (us[j]&&b[j]==c) { printf ("%d %d\n",i,j); break; }
	}

    return 0;
}


#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }

bitset <N> a[N],b[N],us,c,f;

int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	int n; sc(n);
	if (n==1) return 0;
	if (n==2) return printf ("%d %d\n",1,2),0;
	for (int i=1; i<=n; i++)
	{
		int m,x; sc(m);
		while (m--) sc(x),a[i][x]=1;
	}
	for (int i=1; i<=n; i++)
		for (int j=i+1; j<=n; j++) if ((c=a[i]&a[j]).count ()==2)
		{
			int x=0,y=0;
			for (int k=1; k<=n; k++) if (c[k])
			{
				if (!x) x=k;
				else { y=k; break; }
			}
			if (b[x][y]) continue;
			b[x][y]=b[y][x]=us[x]=us[y]=1,printf ("%d %d\n",x,y);
		}
	for (int i=1; i<=n; i++)
		b[i][i]=1;
	for (int i=1; i<=n; i++) if (us[i])
	{
		for (int j=1; j<=n; j++) if (b[i]==(c=a[j]&us))
		{
			c^=a[j];
			for (int k=1; k<=n; k++) if (c[k])
				printf ("%d %d\n",i,k),b[i][k]=b[k][i]=1,us[k]=1;
			break;
		}
	}

    return 0;
}


#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }

bitset <N> a[N],b[N],us,c,f;

int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	int n; sc(n);
	if (n==1) return 0;
	if (n==2) return printf ("1 2\n"),0;
	if (n==3) return printf ("1 2\n2 3\n"),0;
	for (int i=1; i<=n; i++)
	{
		int m,x; sc(m);
		while (m--) sc(x),a[i][x]=1;
	}
	for (int i=1; i<=n; i++)
		for (int j=i+1; j<=n; j++) if ((c=a[i]&a[j]).count ()==2)
		{
			int x=0,y=0;
			for (int k=1; k<=n; k++) if (c[k])
			{
				if (!x) x=k;
				else { y=k; break; }
			}
			if (b[x][y]) continue;
			b[x][y]=b[y][x]=us[x]=us[y]=1,printf ("%d %d\n",x,y);
		}
	for (int i=1; i<=n; i++)
		b[i][i]=1;
	for (int i=1; i<=n; i++) if (us[i])
	{
		for (int j=1; j<=n; j++) if (b[i]==(c=a[j]&us))
		{
			c^=a[j];
			for (int k=1; k<=n; k++) if (c[k])
				printf ("%d %d\n",i,k),b[i][k]=b[k][i]=1,us[k]=1;
			break;
		}
	}

    return 0;
}


#include<bits/stdc++.h>
#define P pair<int,int>
#define fir first
#define sec second
using namespace std;
const int N=1005;
vector<P> vec[N];
bitset<N> bit[N];
int n,f[N],x,u,v,k;
int find(int x){return x==f[x]?x:f[x]=find(f[x]);}
void merge(int x,int y){f[find(x)]=find(y);}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&k);
		while (k--) scanf("%d",&x),bit[x][i]=1;
	}
	if (n==2) return puts("1 2"),0;
	for (int i=1;i<=2*n;i++) f[i]=i;
	for (int i=1;i<=n;i++)
	  for (int j=i+1;j<=n;j++)
	  {
	  	int cnt=(int)(bit[i]&bit[j]).count();
	  	if (cnt==1) merge(i,j),merge(i+n,j+n);
	  	else if (cnt==2) merge(i+n,j),merge(i,j+n);
	  	else vec[cnt].push_back(P(i,j));
	  }
	if (vec[n].size()==n*(n-1)/2)//特判星
	{
		for (int i=2;i<=n;i++) printf("1 %d\n",i);
		return 0;
	}
	if (vec[n].size()==1)//特判流星锤
	{
		printf("%d %d\n",u=vec[n][0].fir,v=vec[n][0].sec);
		for (int i=1;i<=n;i++)
		  if (i!=u&&i!=v) {merge(i,u),merge(i+n,u+n),merge(i+n,v),merge(i,v+n);break;}
		for (int i=1;i<=n;i++)
		  if (i!=u&&i!=v)
		    if (find(i)==find(u)) printf("%d %d\n",i,u);else printf("%d %d\n",i,v);
	    return 0;
	}
	for (int i=n;i>=3;i--)
	  for (int j=0;j<vec[i].size();j++)
	    if (u=vec[i][j].fir,v=vec[i][j].sec,find(u)!=find(v))
	    {
	   	   printf("%d %d\n",u,v);
	   	   merge(u+n,v);merge(u,v+n);
		}
	return 0;
}


#include<bits/stdc++.h>
#define P pair<int,int>
#define fir first
#define sec second
using namespace std;
const int N=1005;
vector<P> vec[N];
bitset<N> bit[N];
int n,f[2*N],x,u,v,k;
int find(int x){return x==f[x]?x:f[x]=find(f[x]);}
void merge(int x,int y){f[find(x)]=find(y);}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&k);
		while (k--) scanf("%d",&x),bit[x][i]=1;
	}
	if (n==2) return puts("1 2"),0;
	for (int i=1;i<=2*n;i++) f[i]=i;
	for (int i=1;i<=n;i++)
	  for (int j=i+1;j<=n;j++)
	  {
	  	int cnt=(int)(bit[i]&bit[j]).count();
	  	if (cnt==1) merge(i,j),merge(i+n,j+n);
	  	else if (cnt==2) merge(i+n,j),merge(i,j+n);
	  	else vec[cnt].push_back(P(i,j));
	  }
	if (vec[n].size()==n*(n-1)/2)//特判星
	{
		for (int i=2;i<=n;i++) printf("1 %d\n",i);
		return 0;
	}
	if (vec[n].size()==1)//特判流星锤
	{
		printf("%d %d\n",u=vec[n][0].fir,v=vec[n][0].sec);
		for (int i=1;i<=n;i++)
		  if (i!=u&&i!=v) {merge(i,u),merge(i+n,u+n),merge(i+n,v),merge(i,v+n);break;}
		for (int i=1;i<=n;i++)
		  if (i!=u&&i!=v)
		    if (find(i)==find(u)) printf("%d %d\n",i,u);else printf("%d %d\n",i,v);
	    return 0;
	}
	for (int i=n;i>=3;i--)
	  for (int j=0;j<vec[i].size();j++)
	    if (u=vec[i][j].fir,v=vec[i][j].sec,find(u)!=find(v))
	    {
	   	   printf("%d %d\n",u,v);
	   	   merge(u+n,v);merge(u,v+n);
		}
	return 0;
}


#include<bits/stdc++.h>
#define P pair<int,int>
#define fir first
#define sec second
using namespace std;
const int N=1005;
vector<P> vec[N];
bitset<N> bit[N];
int n,f[N],x,u,v,k;
int find(int x){return x==f[x]?x:f[x]=find(f[x]);}
void merge(int x,int y){f[find(x)]=find(y);}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&k);
		while (k--) scanf("%d",&x),bit[x][i]=1;
	}
	for (int i=1;i<=2*n;i++) f[i]=i;
	for (int i=1;i<=n;i++)
	  for (int j=i+1;j<=n;j++)
	  {
	  	int cnt=(int)(bit[i]&bit[j]).count();
	  	if (cnt==1) merge(i,j),merge(i+n,j+n);
	  	else if (cnt==2) merge(i+n,j),merge(i,j+n);
	  	else vec[cnt].push_back(P(i,j));
	  }
	if (vec[n].size()==n*(n-1)/2)//特判星
	{
		for (int i=2;i<=n;i++) printf("1 %d\n",i);
		return 0;
	}
	if (vec[n].size()==1)//特判流星锤
	{
		printf("%d %d\n",u=vec[n][0].fir,v=vec[n][0].sec);
		for (int i=1;i<=n;i++)
		  if (i!=u&&i!=v) {merge(i,u),merge(i+n,u+n),merge(i+n,v),merge(i,v+n);break;}
		for (int i=1;i<=n;i++)
		  if (i!=u&&i!=v)
		    if (find(i)==find(u)) printf("%d %d\n",i,u);else printf("%d %d\n",i,v);
	    return 0;
	}
	for (int i=n;i>=3;i--)
	  for (int j=0;j<vec[i].size();j++)
	    if (u=vec[i][j].fir,v=vec[i][j].sec,find(u)!=find(v))
	    {
	   	   printf("%d %d\n",u,v);
	   	   merge(u+n,v);merge(u,v+n);
		}
	return 0;
}


#include<iostream>
#include<cstdio>
#include<bitset>
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=2020;
int n,m,x,u,v;
bitset<N>b[N],g[N],bo,c;
void add(int u,int v){g[u][v]=g[v][u]=1;}
int main(){
	scanf("%d",&n);
	FOR(i,1,n){
		scanf("%d",&m);
		while(m--) scanf("%d",&x),b[i][x]=1;
	}
	FOR(i,1,n)FOR(j,1,n){
		c=b[i]&b[j];
		if(c.count()==2){
			u=c._Find_first(),v=c._Find_next(u);
			add(u,v);bo|=c;
		}
	}
	if(bo.count()==0)
		FOR(i,2,n) add(1,i);
	else if(bo.count()==2){
		u=bo._Find_first(),v=bo._Find_next(u);
		FOR(i,1,n)if(b[i].count()<n){
			FOR(j,1,n)if(!bo[j]) add(b[i][j]?u:v,j);
			break;
		}
	}
	else FOR(i,1,n)if(!bo[i]){
		c=bo;
		FOR(j,1,n)if(b[j][i]) c&=b[j];
		u=c._Find_first();add(u,i);
	}
	FOR(i,1,n)FOR(j,i+1,n)if(g[i][j]) cout<<i<<' '<<j<<'\n';
}


#include<iostream>
#include<cstdio>
#include<bitset>
#include "assert.h"
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=1010;
int n,m,x,u,v,cnt;
bitset<N>b[N],g[N],f[N],bo,c;
void add(int u,int v){g[u][v]=g[v][u]=1;}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d",&n);
	FOR(i,1,n){
		scanf("%d",&m);
		while(m--) scanf("%d",&x),b[i][x]=1;
	}
	FOR(i,1,n)FOR(j,1,n){
		c=b[i]&b[j];
		if(c.count()==2){
			u=c._Find_first(),v=c._Find_next(u);
			f[u][v]=f[v][u]=1;add(u,v);bo|=c;
		}
	}
	FOR(i,1,n)if(bo[i]) f[i][i]=1;
	if(bo.count()==0)
		FOR(i,2,n) add(1,i);
	else if(bo.count()==2){
		u=bo._Find_first(),v=bo._Find_next(u);
		FOR(i,1,n)if(b[i].count()<n){
			FOR(j,1,n)if(!bo[j]) add(b[i][j]?u:v,j);
			break;
		}
	}
	else FOR(i,1,n)if(!bo[i]){
		int m=n;
		FOR(j,1,n)if(b[j][i] && (bo&b[j]).count()<m)
			c=bo&b[j],m=c.count();
		FOR(j,1,n)if(c[j] && f[j]==c) add(j,i);
	}
	FOR(i,1,n)FOR(j,i+1,n)if(g[i][j]) cout<<i<<' '<<j<<'\n',cnt++;
	assert(cnt==n-1);
}


#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i ++)
#define rep1(i, n) for(int i = 1; i <= (n); i ++)
#define MP make_pair
typedef long long LL;
typedef pair<int, int> PII;

const int INF = 1e9 + 7;

int n;
bitset<1005> occ[1005];
int cnt[1005][1005];

int vis[1005];
void dfs(int v, int dat)
{
	if(vis[v] != -1) return;
	vis[v] = dat;
	rep1(i, n) if(cnt[v][i] == 1) dfs(i, dat);
	else if(cnt[v][i] == 2) dfs(i, !dat);
}

int main()
{
	scanf("%d", &n);
	rep(i, n) {
		int k, x;
		scanf("%d", &k);
		rep(j, k) {
			scanf("%d", &x);
			occ[x][i] = true;
		}
	}

	if(n == 2) {
		printf("1 2\n");
		return 0;
	}

	rep1(i, n) rep1(j, i - 1)
	cnt[i][j] = cnt[j][i] = (occ[i] & occ[j]).count();

	int maxl = 2;
	rep1(i, n) rep1(j, n) {
		if(cnt[i][j] == 1) maxl = 4;
		else if(cnt[i][j] == 2) maxl = 3;
	}
	if(maxl == 2) {
		rep1(i, n - 1) printf("%d %d\n", i, n);
		return 0;
	}

	int beg = 1;
	rep1(i, n) rep1(j, n) if(cnt[i][j] == 2) beg = i;
	rep1(i, n) rep1(j, n) if(cnt[i][j] == 1) beg = i;

	rep1(i, n) vis[i] = -1;
	dfs(beg, 0);
	int cur = 1;
	rep1(i, n) if(vis[i] == -1) dfs(i, cur ^= 1);

	rep1(i, n) rep1(j, i - 1)
	if(cnt[i][j] > 2 && vis[i] != vis[j]) printf("%d %d\n", j, i);
	return 0;
}