10777 - Exam Seat Arrangement   

Description

Students are asked to take seats arranged by TAs in an exam.  The seats in the classroom are in M rows and N columns.  Each seat assignment has three numbers: row ID, column ID, and student ID.  Based on those information, print the final seat assignment in the classroom.

 

For example, suppose the classroom has seats in 4 rows by 2 columns, and three students attend the exam, whose IDs are 104062997, 104062998, and 104062999.  The input will be like

4 2 3

1 2 104062999

3 1 104062997

4 2 104062998

The first two number means there are 4 rows by 2 columns seats in the classroom, and there are 3 students in the exam.  Student 104062999 is sited in the row 1 and column 2; student 104062997 is sited in the row 3 and column 1; and student 104062998 is sited in the row 4 and column 2.  The seat arrangement is given below

 

 

Your output should be

                 0  104062999

                 0                  0

 104062997                  0

                 0  104062998

 

If a seat is not assigned to any student, your output should print 0.  Since the student ID has 9 digits, each number in the output takes 9 digits space.

Input

The first line of the input has three numbers: rows of the classroom M, columns of the classroom N and the number of attendees K. Each of the following K lines contains three integers: row number, column number, and student ID. Row number starts from 1 to M, column number starts from 1 to N. 0 < M, N < 40.

Output

M rows, each row has N numbers. Each number takes 9-digit space, neighboring numbers are separated by a space. And there is a ‘\n’ at the end of each line.

Sample Input  Download

Sample Output  Download

Tags

10401Mid1



Discuss