#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int r[n];
    int c[n];
    for(int i=0;i<n;++i)
    {
        cin >> r[i] >> c[i];
    }
    int counter = 0;
    for(int i=0;i<n;++i)
    {
        for(int j=i+1;j<n;++j)
        {
            if(r[i] == r[j])
                counter++;
        }
    }
    for(int i=0;i<n;++i)
    {
        for(int j=i+1;j<n;++j)
        {
            if(c[i] == c[j])
                counter++;
        }
    }
    if(counter == 0)
    {
        cout << 0;
    }
    else
    {
        cout << 1;
    }

    return 0;
}