시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
5 초 512 MB 4 1 1 50.000%

문제

"Divisor is the Conquerer"은 혼자 할 수 있는 카드 게임이다. 보통 이런 단순한 게임은 시간을 보내기 좋은 방법이지만, 프로그래머인 당신은 그 시간에 프로그래밍을 하고 싶을 것이다. 당신의 과제는 "Divisor is the Conquerer" 게임을 자동으로 해결하는 컴퓨터 프로그램을 만드는 것이다. 아래에 게임 규칙이 있다.

먼저, 무작위로 N개의 카드를 카드 덱에서 뽑는다 (1 ≤ N ≤ 52). 게임은 뽑은 카드들만을 이용해서 진행되고, 다른 카드들은 사용되지 않을 것이다.

그뒤 반복해서 한 장씩 카드를 바닥에 내려놓는다. 맨 처음 내려놓을 때는 어떤 카드이든 내려놓을 수 있다. 그 뒤에는 내려놓은 카드들을 "지배하는" 카드만을 내려놓을 수 있다. 어떤 카드가 카드들의 집합을 지배한다는 것은 카드가 의미하는 수가 카드 집합의 수들의 합을 나눈다는 것이다. 예를 들어, 카드 7은 집합 {5, 11, 12}를 지배하지만, 카드 11은 집합 {5, 7, 12}를 지배하지 않는다. 

처음에 고른 N개의 카드를 모두 내려놓으면 게임에 승리하게 된다. 이것에 실패하면, 즉 중간에 카드를 내려놓을 수 없게 되면 패배한 것이다.

입력

입력은 여러 개의 테스트 케이트로 구성된다.

각 테스트 케이스는 두 줄로 이루어진다. 첫번째 줄에는 카드의 개수를 의미하는 정수 N (1 ≤ N ≤ 52) 이 있다. 두번째 줄은 각 카드가 의미하는 숫자를 뜻하는 N개의 정수  c, . . . , cN (1 ≤ ci ≤ 13) 로 구성된다. 한 테스트 케이스에서 같은 수를 의미하는 카드의 개수가 최대 4개까지라는 것을 가정해도 된다.

0이 입력되면 입력이 끝난다.

출력

각각의 테스트 케이스에 대해 한 줄씩 출력한다. 입력된 초기 조건에서 이길 수 있는 전략이 있으면, 가능한 전략 중 아무거나 N개짜리 정수 목록으로 공백으로 구분하여 출력한다.

만약 이길 수 있는 방법이 없으면, “No”라고 출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