#D11882. Playing With Stones

    ID: 9879 Type: Default 1000ms 268MiB

Playing With Stones

Playing With Stones

Playing with Stones

Koshiro and Ukiko are playing a game with black and white stones. The rules of the game are as follows:

  1. Before starting the game, they define some small areas and place "one or more black stones and one or more white stones" in each of the areas.

  2. Koshiro and Ukiko alternately select an area and perform one of the following operations. (a) Remove a white stone from the area (b) Remove one or more black stones from the area. Note, however, that the number of the black stones must be less than or equal to white ones in the area. (c) Pick up a white stone from the stone pod and replace it with a black stone. There are plenty of white stones in the pod so that there will be no shortage during the game.

  3. If either Koshiro or Ukiko cannot perform 2 anymore, he/she loses.

They played the game several times, with Koshiro’s first move and Ukiko’s second move, and felt the winner was determined at the onset of the game. So, they tried to calculate the winner assuming both players take optimum actions.

Given the initial allocation of black and white stones in each area, make a program to determine which will win assuming both players take optimum actions.

Input

The input is given in the following format.

NN w1w_1 b1b_1 w2w_2 b2b_2 : wNw_N bNb_N

The first line provides the number of areas NN (1N100001 \leq N \leq 10000). Each of the subsequent NN lines provides the number of white stones wiw_i and black stones bib_i (1wi,bi1001 \leq w_i, b_i \leq 100) in the ii-th area.

Output

Output 0 if Koshiro wins and 1 if Ukiko wins.

Examples

Input

4 24 99 15 68 12 90 95 79

Output

0

Input

3 2 46 94 8 46 57

Output

1

inputFormat

Input

The input is given in the following format.

NN w1w_1 b1b_1 w2w_2 b2b_2 : wNw_N bNb_N

The first line provides the number of areas NN (1N100001 \leq N \leq 10000). Each of the subsequent NN lines provides the number of white stones wiw_i and black stones bib_i (1wi,bi1001 \leq w_i, b_i \leq 100) in the ii-th area.

outputFormat

Output

Output 0 if Koshiro wins and 1 if Ukiko wins.

Examples

Input

4 24 99 15 68 12 90 95 79

Output

0

Input

3 2 46 94 8 46 57

Output

1

样例

4
24 99
15 68
12 90
95 79
0