시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 329 172 156 54.545%

문제

소수를 매우 좋아하는 수학자가 있다. 이 수학자는 매번 전화번호를 받을 때 마다, 그 전화번호가 소수인지 아닌지를 검사한다. 수학자는 자신의 모든 친구의 전화번호가 소수인지 아닌지를 기억하고 있다.

계속해서 늘어나는 휴대전화 인구의 급증에 따라 정부는 한 자리를 기존 번호 앞에 붙이는 정책을 시행하기로 했다.

수학자는 큰 고민에 빠졌다. 소수 전화번호를 가지고 있는 친구의 전화번호가 이제 평범한 숫자가 될 수도 있기 때문이다.

수학자의 친구 중 한 사람의 원래 전화번호와 새로이 앞에 붙는 번호 한 자리가 주어졌을 때, 원래 전화번호와 새로운 전화번호가 모두 소수인지 아닌지를 구하는 프로그램을 작성하시오.

입력

첫째 줄에 여섯 자리의 기존 전화번호와 새로 추가되는 한 자리 번호가 주어진다. 기존 전화번호는 0으로 시작하지 않으며, 새로 추가되는 한 자리 번호는 0이 아니다.

출력

원래 전화번호와 새로운 전화번호가 소수이면 Yes를, 아니면 No를 출력한다.

예제 입력 1

946859 2

예제 출력 1

Yes
W3sicHJvYmxlbV9pZCI6Ijc3ODkiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWQxNTRcdWI4MDhcdWQ1MDRcdWI3N2NcdWM3ODQiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YzE4Y1x1YzIxOFx1Yjk3YyBcdWI5ZTRcdWM2YjAgXHVjODhiXHVjNTQ0XHVkNTU4XHViMjk0IFx1YzIxOFx1ZDU1OVx1Yzc5MFx1YWMwMCBcdWM3ODhcdWIyZTQuIFx1Yzc3NCBcdWMyMThcdWQ1NTlcdWM3OTBcdWIyOTQgXHViOWU0XHViYzg4IFx1YzgwNFx1ZDY1NFx1YmM4OFx1ZDYzOFx1Yjk3YyBcdWJjMWJcdWM3NDQgXHViNTRjIFx1YjljOFx1YjJlNCwgXHVhZGY4IFx1YzgwNFx1ZDY1NFx1Ym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