题目描述

You have an $n \times n$ grid. Each cell contains an integer. The number at the $i$-th row and $j$-th column has initial value $a\_{i, j}(1\leq i, j \leq n)$. In one operation you can choose a cell $(i, j)$ and an integer $x$ such that $|x| \leq 10^9$ and do the following:

  • Add $x$ to each number in the $i$-th row. Then, subtract $x$ from each number in the $j$-th column.

Determine whether you can make all numbers non-negative within $1000$ operations. If so, construct a solution.


输入格式

The first line contains a single integer $n(1 \leq n \leq 501)$.

The next $n$ lines each contains $n$ integers. The $j$-th integer on the $i$-th line is $a_{i, j}(0 \leq |a_{i, j}| \leq 10^6)$.


输出格式

If your goal cannot be achieved, print one integer $-1$ in a line.

Otherwise print integer $k(0 \leq k \leq 1000)$ in the first line, indicating the number of operations. Then print $k$ lines. Each line contains three integers $i, j, x$ separated by a single space, indicating one operation. You must make sure $1 \leq i, j \leq n, 0 \leq |x| \leq 10^9$.


样例数据

输入

3
6 5 -4
-7 2 0
3 26 47

输出

5
1 1 3
2 1 -12
2 2 10
3 2 -10
3 3 -2

备注


操作

评测记录

优秀代码

信息

时间限制: 1s
内存限制: 256MB
评测模式: Normal

题解