Practice | 프로그래밍의 벗 PivotOJ
PivotOJ

Practice

시간 제한: 1000ms메모리 제한: 1024MB출처: EIO 2020-21 openBOJ 29883

문제

John practiced for NN days in preparation for the olympiad. He solved XiX_i tasks on day ii.

After the olympiad he wanted to know whether there was a span of consecutive days when he solved exacly YY tasks. In other words, are there integers aa and bb such that 1abN1 \le a \le b \le N and Xa+Xa+1++Xb=YX_a + X_{a+1} + \ldots + X_b = Y?

Write a program to help John answer that question.

입력

The first line of input contains NN, the number of days (1N10001 \le N \le 1\,000), and MM, the number of questions (1M10000001 \le M \le 1\,000\,000).

The second line contains NN space-separated integers XiX_i (0Xi10000 \le X_i \le 1\,000, where 1iN1 \le i \le N), the numbers of tasks John solved each day.

The third line contains MM space-separated integers YjY_j (1Yj10000001 \le Y_j \le 1\,000\,000, where 1jM1 \le j \le M), the numbers of tasks in John's questions.

출력

Output MM lines, one per question. On the line jj output the word 'JAH', if there exists a span of consecutive days when John solved exactly YjY_j tasks, or the word 'EI', if there's no such span of days.

예제

예제 1

입력
3 4
1 2 3
2 7 5 4
출력
JAH
EI
JAH
EI
코드를 제출하려면 로그인하세요.