아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Practice

면접 대비

시간 제한1초메모리 제한1024 MB

요약
N일 동안의 일일 문제 수가 주어질 때, 연속한 구간의 합이 주어진 값이 되는지 묻는 M개의 질의에 답한다.
난이도

보통10점 중 5점

유형
누적 합, 해시맵, 배열, 완전 탐색
정답자
아직 제출이 없습니다

문제

John practiced for NN days in preparation for the olympiad. He solved X_iX\_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 1≤a≤b≤N1 \le a \le b \le N and X_a+X_a+1+…+X_b=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 (1≤N≤1,0001 \le N \le 1\\,000), and MM, the number of questions (1≤M≤1,000,0001 \le M \le 1\\,000\\,000).

The second line contains NN space-separated integers X_iX\_i (0≤X_i≤1,0000 \le X\_i \le 1\\,000, where 1≤i≤N1 \le i \le N), the numbers of tasks John solved each day.

The third line contains MM space-separated integers Y_jY\_j (1≤Y_j≤1,000,0001 \le Y\_j \le 1\\,000\\,000, where 1≤j≤M1 \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 Y_jY\_j tasks, or the word 'EI', if there's no such span of days.

예제1

  1. 예제 1

    입력
    3 4
    1 2 3
    2 7 5 4
    
    예상 출력
    JAH
    EI
    JAH
    EI