P29706 [洛谷] [COCI2009-2010#2] KUTEVI
普及
题目描述

Problem Description

Given \( N \) angles (the \( i \)-th angle is denoted as \( a_i \)) as initial angles, and another \( M \) angles (the \( i \)-th angle is denoted as \( b_i \)) as target angles.

Determine for each \( b_i \) whether it can be obtained through addition and subtraction operations among the \( a_i \)'s.

Note that the same \( a_i \) can be used multiple times or not at all.

Input Format

The first line contains two positive integers \( N \) and \( M \).

The second line contains \( N \) positive integers, where the \( i \)-th number is \( a_i \).

The third line contains \( M \) positive integers, where the \( i \)-th number is \( b_i \).

Output Format

Output \( M \) lines. On the \( i \)-th line, if \( b_i \) can be obtained through addition and subtraction operations among the \( a_i \)'s, output YES; otherwise, output NO.

Sample Input and Output

Input Example #1

2 1
30 70
40

Output Example #1

YES

Input Example #2

1 1
100
60

Output Example #2

YES

Input Example #3

3 2
10 20 30
5 70

Output Example #3

NO
YES

Notes

Sample Explanation

Example 1 Explanation:

\( 70^\circ - 30^\circ = 40^\circ \).

Example 2 Explanation:

\( 15 \times 100^\circ = 1500^\circ = 60^\circ \).

Data Range and Constraints

\( 1 \leq N, M \leq 10 \), \( 0 < a_i, b_i < 360 \).

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 1 30 70 40
样例输出
YES