Simulate a two-player game where each spoken prime is recorded per player, duplicates cost 1000 points, and a non-prime gives the opponent their third largest prime or 1000.
Medium4SimulationImplementationNumber theorySortingNo attempts yetTime limit2sMemory limit256 MBDaewoong, a student at Inha University, loves number theory. At some point he started memorizing primes, and now he can tell whether any number he hears is prime. When a rumor spread that Inha University has a god of primes, Gyuseong, the prime master of Insang University, challenged Daewoong.
The two decided to bet on who loves primes more. Since there is no way to measure that directly, they settle it with the prime game.
The rules of the prime game are as follows.
0 and 1 are not prime. Both players start with 0 points. Print the winner of the prime game played under these rules.
The first line contains N, the number of rounds. (5≤N≤100000)
Each of the next N lines contains the integers said by Daewoong and Gyuseong in that round, in this order, separated by a space. In each round Daewoong speaks first and Gyuseong speaks second. Every integer is at least 0 and less than 5000000.
After all rounds, the player with the higher score wins. Print 소수의 신 갓대웅 if Daewoong wins and 소수 마스터 갓규성 if Gyuseong wins. If the scores are equal, print 우열을 가릴 수 없음. Print these Korean strings exactly as shown.