| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 53 | 34 | 26 | 61.905% |
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'.