Matrix
题号:NC13883
时间限制:C/C++/Rust/Pascal 4秒,其他语言8秒
空间限制:C/C++/Rust/Pascal 128 M,其他语言256 M
64bit IO Format: %lld

题目描述

Today HH is palying with a n×n matrix.
 All the numbers of the matrix is 0 initial, and every time HH will do one of the following things:
1.make all the numbers in the k row become v
2.make all the numbers in the k column become v
Now HH wants to know what's the final matrix after q options.     

输入描述:

The first line contains an positive integer T(1≤T≤10), represents there are T test cases. 
For each test case: 
The first line contains two positive integers n,q(1≤n≤500,1≤q≤2*105) - the size of the matrix and the times of the options. 
 Then q lines following, for each line contains three integers op,k,v(1≤op≤2,1≤k≤n,1≤v≤100). 
 if op=1, then HH will change all the numbers in the k row into v 
 if op=2, then HH will change all the numbers in the k column into v

输出描述:

For each test case, you should output n lines , each line n numbers , indicating the final matrix, note that for each line ,you should print exactly one blank between two numbers.
示例1

输入

复制
1
3 3
1 2 3
2 2 1
1 1 3

输出

复制
3 3 3
3 1 3
0 1 0