Count Specific ElementsEasy

Count Specific Elements

EasyPractice library · +10 XPhash mapcountingfrequency

Given a list of N integers, and a list of K special integers, count how many times each special integer appears in the given list. Print the counts for each special integer in the order they appear in the special integers list.

Input

The first line contains two integers N and K, separated by a space. The second line contains N integers, the list of numbers. The third line contains K integers, the list of special numbers.

Output

Print K integers, where the i-th integer is the count of the i-th special number in the list of N integers. The counts should be separated by spaces.

Constraints

1 <= N <= 1000 1 <= K <= 1000 Each integer in the lists will be between -1000 and 1000.

Time limit 1 s (native code; slower languages get more)Memory 256 MB13 hidden tests

Example 1

Input
5 3
1 2 3 2 1
1 2 4
Output
2 2 0

The number 1 appears 2 times, 2 appears 2 times, and 4 appears 0 times.

Example 2

Input
7 4
10 10 20 30 10 20 10
10 20 30 40
Output
4 2 1 0

10 appears 4 times, 20 appears 2 times, 30 appears 1 time, and 40 appears 0 times.

Hints