시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 148 80 74 56.923%

문제

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

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

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

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

입력

첫째 줄에 여섯 자리의 기존 전화번호와 새로 추가되는 한 자리 번호가 주어진다.

출력

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

예제 입력 1

946859 2

예제 출력 1

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