A. 宠物店

传统 1000 ms 256 MiB
标准 IO
文本比较

题目描述

宠物店店长发现店里好吃懒做的宠物越来越多了。特别是猪,只会睡大觉,结果出题费被扣一半;猫则逐渐只会唱哈基米。为了整治宠物店的不良风气,让宠物们有真才实学,店长决定开设算术课,让宠物们学习算术。

某天,店长让 n2n^2 只宠物排成 nnnn 列的方阵,行和列的编号均为 1,2,,n1,2,\cdots,n。店长决定玩一个小游戏,来测试宠物们的算术能力。每只宠物都记着一个整数,初始时均为 00。店长将依次发出 mm 条命令,命令分四种:

  • 1 k\texttt{1 }k:所有宠物都把各自的数加上 kk
  • 2 x k\texttt{2 }x\texttt{ }k:第 xx 行的所有宠物都把各自的数加上 kk
  • 3 y k\texttt{3 }y\texttt{ }k:第 yy 列的所有宠物都把各自的数加上 kk
  • 4 x y\texttt{4 }x\texttt{ }y:询问第 xx 行第 yy 列的那只宠物当前自己的数是多少。

对于每条第 4 种命令,请你回答这只宠物此时应报出的数是多少。

在你成功解决本题后,店长想再次提醒你:题目并不是按难度排列的。

输入格式

第一行两个整数 n,mn,m1n20251\le n\le20251m1061\le m\le10^6)。

接下来 mm 行,每行 2233 个整数,表示一条命令,格式见题目描述。

在命令中,保证 1x,yn1\le x,y\le n109k109-10^9\le k\le10^9

输出格式

对于每条第 4 种命令,输出一行一个整数,表示第 xx 行第 yy 列的宠物此时的数应该是多少。

样例

样例 1

输入

3 5
1 9
2 3 -1
4 1 3
3 3 4
4 3 3

输出

9
12

解释

命令 解释
1 9\texttt{1 9} [000000000][999999999]\begin{bmatrix}0&0&0\\0&0&0\\0&0&0\end{bmatrix}\to\begin{bmatrix}\color{red}9&\color{red}9&\color{red}9\\\color{red}9&\color{red}9&\color{red}9\\\color{red}9&\color{red}9&\color{red}9\end{bmatrix}
2 3 -1\texttt{2 3 -1} [999999999][999999888]\begin{bmatrix}9&9&9\\9&9&9\\9&9&9\end{bmatrix}\to\begin{bmatrix}9&9&9\\9&9&9\\\color{red}8&\color{red}8&\color{red}8\end{bmatrix}
4 1 3\texttt{4 1 3} [999999888]\begin{bmatrix}9&9&\color{blue}9\\9&9&9\\8&8&8\end{bmatrix},答案是 99
3 3 4\texttt{3 3 4} [999999888][991399138812]\begin{bmatrix}9&9&9\\9&9&9\\8&8&8\end{bmatrix}\to\begin{bmatrix}9&9&\color{red}{13}\\9&9&\color{red}{13}\\8&8&\color{red}{12}\end{bmatrix}
4 3 3\texttt{4 3 3} [991399138812]\begin{bmatrix}9&9&13\\9&9&13\\8&8&\color{blue}{12}\end{bmatrix},答案是 1212

样例 2

输入

2025 10
4 1394 821
1 998244353
3 985 123456789
2 1024 987654321
3 996 996412345
4 1024 996
1 -1000000000
1 -1000000000
2 2025 -1919810
4 2025 985

输出

0
2982311019
-880218668