Execution time limit is 1 second

Runtime memory usage limit is 128 megabytes

The theater has $n$ rows with $m$ seats. Two matrices are given. The first matrix contains the ticket prices for each seat. The second matrix tells which tickets are sold and which are not ($1$ means the ticket is sold for a corresponding seat, $0$ is not sold).

Determine the total revenue from the performance.

The first line contains $n$ and $m(n,m≤500)$. Then the matrix with ticket prices is given ($n$ lines with $m$ numbers, each number ranges from $0$ to $10000$). Then given the matrix of sold tickets — $n$ lines with $m$ numbers.

Print the total revenue from the ticket sales.

Input #1

Answer #1