Practice
면접 대비시간 제한1초메모리 제한1024 MB
N일 동안의 일일 문제 수가 주어질 때, 연속한 구간의 합이 주어진 값이 되는지 묻는 M개의 질의에 답한다.
문제
John practiced for days in preparation for the olympiad. He solved tasks on day .
After the olympiad he wanted to know whether there was a span of consecutive days when he solved exacly tasks. In other words, are there integers and such that and ?
Write a program to help John answer that question.
입력
The first line of input contains , the number of days (), and , the number of questions ().
The second line contains space-separated integers (, where ), the numbers of tasks John solved each day.
The third line contains space-separated integers (, where ), the numbers of tasks in John's questions.
출력
Output lines, one per question. On the line output the word 'JAH', if there exists a span of consecutive days when John solved exactly tasks, or the word 'EI', if there's no such span of days.