#K51882. Sum of Unique Elements in a Matrix
Sum of Unique Elements in a Matrix
Sum of Unique Elements in a Matrix
You are given a matrix with n rows and m columns. Your task is to compute the sum of all unique elements in the matrix, where an element is considered unique if it appears exactly once.
The sum of unique elements can be written mathematically as:
$$ \text{UniqueSum} = \sum_{x \in U} x $$where \(U\) represents the set of elements that occur only once in the matrix.
Read the matrix from standard input and output the result to standard output.
inputFormat
The first line of input contains two integers \(n\) and \(m\) which denote the number of rows and columns, respectively.
This is followed by \(n\) lines, each containing \(m\) space-separated integers representing the elements of the matrix.
outputFormat
Output a single integer which is the sum of the elements that appear exactly once in the matrix.
## sample3 3
1 2 3
2 1 4
5 6 1
18