#include <iostream>

using namespace std;

int main()
{
    int N, uR, uC, brojac = 0;
    cin>>N;

    int matrica[N][N];
    int duzinaK[N], duzinaR[N];

    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            matrica[i][j] = 0;
        }
    }

    for(int i = 0; i < N; i++)
    {
        cin>>uR>>uC;
        matrica[uR][uC] = 1;
    }

    if(N == 2)
    {
        if(matrica[0][0] == 1 && matrica[1][1] == 1)
            cout<<0;
        else if(matrica[0][1] == 1 && matrica[1][0] == 1)
            cout<<0;
        else cout<<1;
    }
    else cout<<0;
    return 0;
}