#K35372. Sum of Unique Elements in a Matrix

    ID: 25517 Type: Default 1000ms 256MiB

Sum of Unique Elements in a Matrix

Sum of Unique Elements in a Matrix

You are given a 2D matrix of integers with n rows and m columns. Your task is to compute the sum of all elements that appear exactly once in the matrix. In other words, if an element appears more than once, it should not be included in the sum.

The unique property of an element x can be mathematically written as:

$\text{count}(x)=1$

Please note that the input will be provided via stdin and the output must be printed to stdout.

inputFormat

The first line of input contains two integers n and m, representing the number of rows and columns of the matrix respectively. Each of the following n lines contains m space-separated integers representing a row of the matrix.

For example:

3 3
1 2 3
4 5 2
6 7 1

outputFormat

Output a single integer which is the sum of all unique elements in the matrix.

For the above example, the unique elements are 3, 4, 5, 6, 7 and their sum is 25.

## sample
3 3
1 2 3
4 5 2
6 7 1
25