The Game of Lim (Hard)


Submit solution


Points: 12
Time limit: 1.0s
Memory limit: 256M

Authors:
Problem type

In the ancient game of Lim, two aliens take turns removing sticks from \(P\) piles with \(n_i\) sticks in the \(i^{th}\) pile. On each turn, the current player must chose to remove at least \(1\) but no more than \(k_i\) sticks from the \(i^{th}\) pile. Today, we will play the "misère" variation of Lim, where the last alien to take the last stick from the last pile loses.

Input Specification

The first line of input will contain \(P\) \((1 \le P \le 10^{9})\).

The following \(P\) lines of input will contain two integers \(n_i\) \((1 \le n \le 10^{18})\), and \(k_i\) \((1 \le k \le 100)\).

Output Specification

Output YES if the first alien is guaranteed to win if they play perfectly. Otherwise, output NO.

Sample Input 1

7
3 2
5 3
7 4
9 5
11 6
13 7
15 8

Sample Output 1

YES

Sample Input 2

8
8 1
8 2
8 3
8 4
8 5
8 6
8 7
8 8

Sample Output 2

NO

Comments

There are no comments at the moment.