Problem list
Log in
#r03092 · Online Judge > GoldOJ

Count a Value in a Matrix

Bronze II 2.0 s 1024 MB

An $n \times m$ matrix is given, then $Q$ queries, each a value $x$. For each query print how many times $x$ appears in the whole matrix.

Input

Line 1: $n$ $m$. Next $n$ lines: the matrix. Then $Q$ and $Q$ values.

Output

Print the count for each query, one per line.

Example 1

Input
3 3
1 2 1
3 1 2
1 3 1
3
1
2
4
Output
5
2
0
Source
Online Judge > GoldOJ
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code