Simple Operations in Matrix

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Matrix is a mathematical object which arranges data into a rectangular array of N rows and M columns. The rows are indexed from 1 to N, while the columns are indexed from 1 to M. Matrix is very powerful and extremely useful in many applications. In this problem, we are going to focus on two simple operations in matrix: row addition and column addition.

You are given a matrix of integers of N rows and M columns, and Q queries of the following format:

  • row k val: add each element on the k-th row by val,
  • col k val: add each element on the k-th column by val.

Your task is to output the following three numbers after all queries have been performed:

  • sum: the sum of all elements in the matrix,
  • min: the value of the smallest element in the matrix,
  • max: the value of the largest element in the matrix.

See the sample input for clarity

입력

The first line contains two integers: N M (1 ≤ N, M ≤ 50) denoting the size of the matrix (number of rows and columns, respectively). The next N lines, each contains M integers: Ai,j (-100 ≤ Ai,j ≤ 100) denoting the matrix element at the i-th row and j-th column for 1 ≤ iN and 1 ≤ jM, respectively. The next line contains an integer: Q (0 ≤ Q ≤ 100) denoting the number of queries. The next Q lines, each contains a query in one of the following format:

  • row k val (1 ≤ kN; -100 ≤ val ≤ 100)
  • col k val (1 ≤ kM; -100 ≤ val ≤ 100)

출력

The output contains three integers (each separated by a single space) in a single line: sum min max, as described in the problem statement.