using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace qual23
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] ustr = null;
            int[,] tacke = new int[n, 2];
            for (int i = 0; i < n; i++)
            {
                ustr = Console.ReadLine().Split();
                tacke[i, 0] = int.Parse(ustr[0]);
                tacke[i, 1] = int.Parse(ustr[1]);
            }
            if (((tacke[0, 0] == 1 && tacke[0, 1] == 1) && (tacke[1, 0] == 2 && tacke[1, 1] == 2)) || ((tacke[0, 0] == 2 && tacke[0, 1] == 2) && (tacke[1, 0] == 1 && tacke[1, 1] == 1)))
                Console.WriteLine(0);
            else if (((tacke[0, 0] == 1 && tacke[0, 1] == 2) && (tacke[1, 0] == 2 && tacke[1, 1] == 1)) || ((tacke[0, 0] == 2 && tacke[0, 1] == 1) && (tacke[1, 0] == 1 && tacke[1, 1] == 2)))
                Console.WriteLine(0);
            else
                Console.WriteLine(1);
        }
    }
}