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:**

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 <= 10^{3}

1 <= M <= 10^{3}

1 <= Elements of Queue <= 10^{6}

**Example:
Input:**

1

8

1 2 3 4 5 2 3 1

5

1 3 2 9 10

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).

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.

Sulagna | 117 |

RUTVIKHARIPARA | 116 |

janvidavda105190 | 93 |

harshsiddhapura105461 | 93 |

madhursengar24 | 86 |

PiyushPandey4 | 617 |

ASWATHAMA | 561 |

akhyasharma01 | 547 |

john_wick | 521 |

jagrit_07 | 448 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.