Under construction

Still being built. Things may change

Delicious Apples

Interview

Time limit2sMemory limit2048 MB

Summary
For each query p, count the apples with taste at least p that have the largest size among those apples.
Level

Easy3 of 10

Topics
Sorting, Binary search
Solved
No attempts yet

Problem

There are NN apples numbered 1 through NN. The taste of apple ii is tit_i, and its size is sis_i.

You must answer QQ queries. Each query gives an integer pp, and you must print the number of apples with the largest size sis_i among those whose taste tit_i is at least pp. If no apple satisfies the condition, print 0.

Input

The first line contains NN and QQ, separated by a space.

The second line contains the tastes t1,t2,…,tNt_1, t_2, \dots, t_N, separated by spaces.

The third line contains the sizes s1,s2,…,sNs_1, s_2, \dots, s_N, separated by spaces.

Each of the next QQ lines contains one integer pp.

Output

Print QQ lines. For each pp, print the number of apples with the largest size among those with taste tit_i at least pp, one per line, in order.

Constraints

  • 1≤N,Q≤200 0001 \le N, Q \le 200\,000
  • 1≤ti,si≤1 000 000 0001 \le t_i, s_i \le 1\,000\,000\,000
  • 1≤p≤1 000 000 0001 \le p \le 1\,000\,000\,000

Examples1

  1. Example 1

    Input
    5 5
    1 3 2 4 5
    3 2 3 2 1
    1
    2
    3
    4
    5
    
    Expected output
    2
    1
    2
    1
    1