시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 124 32 28 34.146%

문제

상범이와 민균이는 올해에도 어김없이 세계 커플 프로그래밍 대회에 출전한다. 대회 전 날, 이들은 대회 기념으로 달력 놀이를 하며 밤을 지새웠다. 이쯤에서 달력 게임에 대해 설명하자면, 달력 게임은 1900/01/01부터 대회 날짜인 2001/11/04까지의 날짜로 이루어져있는 달력의 랜덤한 날짜에서 게임을 시작한다. 게임은 상범이가 먼저 시작해서 번갈아가며(즉 상범-민균-상범-민균-...) 현재 날짜의 다음 날로 이동하거나, 다음 달의 현재 날짜와 동일한 날짜를 갖는 날로 이동하는 것 중 한 가지를 선택하는 것으로 진행된다. 단, 다음 달의 같은 날짜로 이동하는 것은 그런 날이 존재하는 경우만 가능하다. 즉, 현재 날짜가 1924/12/19일 경우 1924/12/20이나 1925/01/19로 이동하는 두 가지 경우가 모두 가능하지만, 현재 날짜가 2001/01/31일 경우 2001/02/01 한 가지 경우만 가능하다.

게임은 2001/11/04에 먼저 도착하는 플레이어가 승리하고, 만약 이 날짜 이후로 이동하면 그 플레이어는 패배하게 된다.

시작 날짜가 주어졌을 때, 선 플레이어인 상범이에게 필승법이 존재하는지 알아내는 프로그램을 작성해보자.

*이 달력에도 당연히 윤년이 존재한다. 윤년에 대한 설명은 이곳을 클릭하면 확인할 수 있다.

입력

입력의 첫 줄에는 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스는 한 줄에 한 개 씩 시작 날짜가 YYYY MM DD의 형식으로 주어진다. YYYY는 연도를 뜻하고, MM은 월을 뜻하며 DD는 일을 뜻한다. 즉, 2001 11 04 라고 주어질 경우 2001년 11월 04일이란 뜻이다.

출력

한 줄에 한 개씩 각 테스트 케이스에 대해 상범이에게 필승법이 존재할 경우 YES, 그렇지 않을 경우 NO를 출력한다.

예제 입력 1

3
2001 11 3
2001 11 2
2001 10 3

예제 출력 1

YES
NO
NO
W3sicHJvYmxlbV9pZCI6IjczNDMiLCJwcm9ibGVt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