| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 57 | 37 | 29 | 63.043% |
John practiced for $N$ days in preparation for the olympiad. He solved $X_i$ tasks on day $i$.
After the olympiad he wanted to know whether there was a span of consecutive days when he solved exacly $Y$ tasks. In other words, are there integers $a$ and $b$ such that $1 \le a \le b \le N$ and $X_a + X_{a+1} + \ldots + X_b = Y$?
Write a program to help John answer that question.
The first line of input contains $N$, the number of days ($1 \le N \le 1\,000$), and $M$, the number of questions ($1 \le M \le 1\,000\,000$).
The second line contains $N$ space-separated integers $X_i$ ($0 \le X_i \le 1\,000$, where $1 \le i \le N$), the numbers of tasks John solved each day.
The third line contains $M$ space-separated integers $Y_j$ ($1 \le Y_j \le 1\,000\,000$, where $1 \le j \le M$), the numbers of tasks in John's questions.
Output $M$ lines, one per question. On the line $j$ output the word 'JAH', if there exists a span of consecutive days when John solved exactly $Y_j$ tasks, or the word 'EI', if there's no such span of days.
3 4 1 2 3 2 7 5 4
JAH EI JAH EI
John solved $2$ tasks on the seocnd day, so the answer to the first question is 'JAH'. As he only solved $6$ tasks in total, the answer to the second question is obviously 'EI'. From the second to the third day, he solved $2 + 3 = 5$ tasks, so the answer to the third question is 'JAH'. As there is no span of consecutive days when he solved $4$ tasks in total, the answer to the last question is 'EI'.