#CCBCHBAHAI0000088. Trả lời Q truy vấn tần suất trên miền nhỏ

    ID: 1006 Loại: Thông thường 2000ms 256MiB Tried: 0 Đã chấp nhận: 0 Độ khó: 1 Đăng bởi: Nhãn>Programming language basicsStatic arraysIteration techniquesImplementation techniquesWorking with numbersInteger arithmetic

Trả lời Q truy vấn tần suất trên miền nhỏ

Answer Q Frequency Queries on a Small Domain

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem

Given nn integers with 0≤ai≤10000\le a_i\le1000, define

f(x)=∣{i∣0≤i<n, ai=x}∣.f(x)=|\{i\mid0\le i<n,\ a_i=x\}|.

For each of QQ queries xj∈[0,1000]x_j\in[0,1000], print f(xj)f(x_j). Precompute one frequency array and answer each query in O(1)O(1).

Input

The first line contains nn and QQ. The second line contains the array. The third line contains QQ query values, all in [0,1000][0,1000].

Output

For each query, print its frequency on a separate line in query order.

Subtask

Subtask 1 (20 points): 1≤n,Q≤101\le n,Q\le10.

Subtask 2 (30 points): 1≤n,Q≤50001\le n,Q\le5000.

Subtask 3 (50 points): 1≤n,Q≤2⋅1051\le n,Q\le2\cdot10^5.

Example

Input

8 5
2 5 2 0 5 5 7 2
5 2 1 0 7

Output

3
3
0
1
1

Explanation

The result follows directly from the mathematical definition above.