Codeforces Round 652 (Div. 2)
F
BareLee
Codeforces
2700
原题
← E→
翻译中…

Lee is used to finish his stories in a stylish way, this time he barely failed it, but Ice Bear came and helped him. Lee is so grateful for it, so he decided to show Ice Bear his new game called "Critic"...

翻译中…

The game is a one versus one game. It has $t$ rounds, each round has two integers $s_i$ and $e_i$ (which are determined and are known before the game begins, $s_i$ and $e_i$ may differ from round to round). The integer $s_i$ is written on the board at the beginning of the corresponding round.

翻译中…

The players will take turns. Each player will erase the number on the board (let's say it was $a$) and will choose to write either $2 \cdot a$ or $a + 1$ instead. Whoever writes a number strictly greater than $e_i$ loses that round and the other one wins that round.

翻译中…

Now Lee wants to play "Critic" against Ice Bear, for each round he has chosen the round's $s_i$ and $e_i$ in advance. Lee will start the first round, the loser of each round will start the next round.

翻译中…

The winner of the last round is the winner of the game, and the loser of the last round is the loser of the game.

翻译中…

Determine if Lee can be the winner independent of Ice Bear's moves or not. Also, determine if Lee can be the loser independent of Ice Bear's moves or not.

翻译中…

Input

翻译中…

The first line contains the integer $t$ ($1 \le t \le 10^5$) — the number of rounds the game has.

翻译中…

Then $t$ lines follow, each contains two integers $s_i$ and $e_i$ ($1 \le s_i \le e_i \le 10^{18}$) — the $i$-th round's information.

翻译中…

The rounds are played in the same order as given in input, $s_i$ and $e_i$ for all rounds are known to everyone before the game starts.

翻译中…

Output

翻译中…

Print two integers.

翻译中…

The first one should be 1 if Lee can be the winner independent of Ice Bear's moves, and 0 otherwise.

翻译中…

The second one should be 1 if Lee can be the loser independent of Ice Bear's moves, and 0 otherwise.

翻译中…

Note

翻译中…

Remember, whoever writes an integer greater than $e_i$ loses.

翻译中…

样例

Input #1
3
5 8
1 4
3 10
Output #1
1 1
InputCopy OutputCopy
Input #2
4
1 2
2 3
3 4
4 5
Output #2
0 0
InputCopy OutputCopy
Input #3
1
1 1
Output #3
0 1
InputCopy OutputCopy
Input #4
2
1 9
4 5
Output #4
0 0
InputCopy OutputCopy
Input #5
2
1 2
2 8
Output #5
1 0
InputCopy OutputCopy
Input #6
6
216986951114298167 235031205335543871
148302405431848579 455670351549314242
506251128322958430 575521452907339082
1 768614336404564650
189336074809158272 622104412002885672
588320087414024192 662540324268197150
Output #6
1 0
InputCopy OutputCopy
题目信息
题号
1369F
时间限制
2 s
内存限制
256 MB
标签
DFS 及类似
动态规划
博弈论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。