Queue Operations
##### Submissions: 2691   Accuracy: 76.59%   Difficulty: Easy   Marks: 2
Associated Course(s):   Fork Java

Here, we will learn operations on queues.

Given N integers, the task is to insert those elements in the queue. Also, given M integers, task is to find the frequency of each number in the Queue.

Input Format:
First line of input contains number of testcases T. For each testcase, there will be four lines. First line contains N, second line contains N integers separated by space. Third line contains M, next line contains M integers separated.

Output Format:
For each testcase, print the frequency of given elements.

Your task is to complete the functions insert() and findFrequency() which inserts the element into the queue and find the count of occurences of element in the queue respectively.

Constraints:
1 <= T <= 100
1 <= N <= 103
1 <= M <= 103
1 <= Elements of Queue <= 106

Example:
Input:

1
8
1 2 3 4 5 2 3 1
5
1 3 2 9 10
Output:
2
2
2
-1
-1

Explanation:
Testcase 1:
After inserting 1, 2, 3, 4, 5, 2, 3, 1 into the queue, frequency of 1 is 2, 3 is 2, 2 is 2, 9 is -1 and 10 is -1 (since, 9 and 10 is not there in the queue).

#### ** For More Input/Output Examples Use 'Expected Output' option **

Author: Dhiman Mayank

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.