Status:  Past  Start:  20141004 12:30:00  End:  20141004 16:30:00 
The 2014 ACMICPC Caribbean National Contests (Real contest)
Problem
2874  Lazy Cat III
Created by  Luis Manuel Díaz Barón 
Added by  luismo (20140501) 
Limits 
Total Time: 90000 MS

Test Time:
6000 MS
Memory: 62 MB  Output: 64 MB  Size:
14 KB

Enabled languages  
Available in 
Description
Anders the cat is receiving his British cousin, who is also known for being the laziest cat in the world: Garfield. After some days together, Garfield proposes to play a game. First, he gives Anders a number 1 <= G <= 100, and Anders must give him another number 1 <= A <= 100. The game follows with 1 <= R <= 10^5 rounds. On each round, Garfield sets an interval [gi, gj] (1 <= gi <= gj <= 10^5) and Anders must answer how many integers in the interval [gi, gj] are coprime with G. Then, Anders must set another interval [ai, aj] (1 <= ai <= aj <= 10^5) and asks Garfield to determine the number of integers in the interval [ai, aj] which are coprime with A.
If a cat answers correctly, he receives 2 points; otherwise he loses 1 point. After R rounds, the cat with the higher total of points wins. If both cats end up with the same number of points, there is a draw. As both cats are well known for their laggardness, they assign you, Anders’ favorite mouse, to check the correctness of each answer and determine who won the game.
;jsessionid=77A2F31657FD8B868F96B9900291A841Anders the cat is receiving his British cousin, who is also known for being the laziest cat in the world: Garfield. After some days together, Garfield proposes to play a game. First, he gives Anders a number 1 <= G <= 100, and Anders must give him another number 1 <= A <= 100. The game follows with 1 <= R <= 10^5 rounds. On each round, Garfield sets an interval [gi, gj] (1 <= gi <= gj <= 10^5) and Anders must answer how many integers in the interval [gi, gj] are coprime with G. Then, Anders must set another interval [ai, aj] (1 <= ai <= aj <= 10^5) and asks Garfield to determine the number of integers in the interval [ai, aj] which are coprime with A.
If a cat answers correctly, he receives 2 points; otherwise he loses 1 point. After R rounds, the cat with the higher total of points wins. If both cats end up with the same number of points, there is a draw. As both cats are well known for their laggardness, they assign you, Anders’ favorite mouse, to check the correctness of each answer and determine who won the game.
;jsessionid=77A2F31657FD8B868F96B9900291A841Anders the cat is receiving his British cousin, who is also known for being the laziest cat in the world: Garfield. After some days together, Garfield proposes to play a game. First, he gives Anders a number 1 <= G <= 100, and Anders must give him another number 1 <= A <= 100. The game follows with 1 <= R <= 10^5 rounds. On each round, Garfield sets an interval [gi, gj] (1 <= gi <= gj <= 10^5) and Anders must answer how many integers in the interval [gi, gj] are coprime with G. Then, Anders must set another interval [ai, aj] (1 <= ai <= aj <= 10^5) and asks Garfield to determine the number of integers in the interval [ai, aj] which are coprime with A.
If a cat answers correctly, he receives 2 points; otherwise he loses 1 point. After R rounds, the cat with the higher total of points wins. If both cats end up with the same number of points, there is a draw. As both cats are well known for their laggardness, they assign you, Anders’ favorite mouse, to check the correctness of each answer and determine who won the game.
;jsessionid=77A2F31657FD8B868F96B9900291A841Input specification
The first line of input contain two integer numbers G and A. The second line contains the number of rounds R. Next, there are R pairs of lines: each pair contains 4 spaceseparated integers in the first line: gi, gj, ai, aj; and two spaceseparated integers on the second line: the Anders' answer and Garfield's answer for the current round.
The first line of input contain two integer numbers G and A. The second line contains the number of rounds R. Next, there are R pairs of lines: each pair contains 4 spaceseparated integers in the first line: gi, gj, ai, aj; and two spaceseparated integers on the second line: the Anders' answer and Garfield's answer for the current round.
The first line of input contain two integer numbers G and A. The second line contains the number of rounds R. Next, there are R pairs of lines: each pair contains 4 spaceseparated integers in the first line: gi, gj, ai, aj; and two spaceseparated integers on the second line: the Anders' answer and Garfield's answer for the current round.
Output specification
The first line of input contain two integer numbers G and A. The second line contains the number of rounds R. Next, there are R pairs of lines: each pair contains 4 spaceseparated integers in the first line: gi, gj, ai, aj; and two spaceseparated integers on the second line: the Anders' answer and Garfield's answer for the current round.
Sample input
17 20
2
1 100 15 20
96 2
10 50 21 49
48 27
Sample output
Garfield wins