#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    if(n == 1){
        int a, b;
        cin >> a >> b;
        cout << 0 << endl;
    }
    else if(n == 2){
        int r0, r1, c0, c1;
        cin >> r0 >> c0 >> r1 >> c1;
        if(r0 == r1 || c0 == c1){
            cout << 1 << endl;
        }
        else cout << 0 << endl;
    }
    //cout << "Hello world!" << endl;
    return 0;
}