시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 508 141 107 29.155%

문제

창영이는 방 청소를 하다가 자와 각도기를 발견했다. 다음날 창영이는 학교에 자와 각도기를 들고 갔고, 현우와 "작도 대결"을 하려고 한다.

창영이는 각도기와 자를 이용해서 만들 수 있는 각을 알고 있고, 두 각을 합하거나 빼서 새로운 각을 만드는 방법을 알고 있다. 현우가 어떤 각도를 외치면, 창영이는 자와 각도기를 이용해서 현우가 외친 각도를 작도해야 한다.

현우가 외치는 각도를 창영이가 만들 수 있는지 없는지 구하는 프로그램을 작성하시오.

입력

첫째 줄에 창영이가 만드는 방법을 알고 있는 각의 수 N과 현우가 외친 각의 개수 K가 주어진다. (1 ≤ N, K ≤ 10)

둘째 줄에는 창영이가 만들 수 있는 각이 주어진다. 모든 각도는 360보다 작다.

셋째 줄에는 현우가 외친 각이 주어진다. 이 각도 360보다 작다.

출력

현우가 외친 각도를 창영이가 만들 수 있다면 YES를, 없다면 NO를 입력으로 주어진 순서대로 한 줄에 하나씩 출력한다.

예제 입력 1

2 1
30 70
40

예제 출력 1

YES

힌트

70도를 만들고, 30도를 빼서 40도를 만들면 된다.

W3sicHJvYmxlbV9pZCI6IjI5MTYiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM3OTBcdWM2NDAgXHVhYzAxXHViM2M0XHVhZTMwIiwiZGVzY3JpcHRpb24iOiI8cD5cclxuXHRcdWNjM2RcdWM2MDFcdWM3NzRcdWIyOTQgXHViYzI5IFx1Y2NhZFx1YzE4Y1x1Yjk3YyBcdWQ1NThcdWIyZTRcdWFjMDAgXHVjNzkwXHVjNjQwIFx1YWMwMVx1YjNjNFx1YWUzMFx1Yjk3YyBcdWJjMWNcdWFjYWNcdWQ1ODhcdWIyZTQuIFx1YjJlNFx1Yzc0Y1x1YjBhMCBcdWNjM2RcdWM2MDFcdWM3NzRcdWIyOTQgXHVkNTU5XHVhZDUwXHVjNWQwIFx1Yzc5MFx1YzY0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