| Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Question by Ibrahim Mesecan.
 
 
   Mr Monk
Mr Monk is a detective who has Obsessive 
Compulsive Disorder (OCD). He cannot stand if there 
is something untidy. He has to put them in order.
 Question: Now, he wants to put 
the numbers in a 2D array in order. But there are 
kcells which he cannot move. 
Help him and put the numbers in order whitout 
moving the cells in the given positions. 
Input specification:  
Firstly, you will be given two integers (n and m) 
size of 2D array. Then, you will be given m integers 
in the following n lines. Next line, you will 
be given an integer (k): the number of blocked cells.
In the following k lines you will be given 
the (x,y) coordinates of k numbers where 1 
≤ (n and m) ≤ 100; 1 ≤ k ≤ 10,000; 
and the numbers in the matrix are less 10,001 Output specification: 
Show the new sorted matrix (sorted
matrix including the blocked cells). 
 
   
| Sample Input I | Sample Input II |  | 
4 37 9 17
 9 14 12
 6 11 7
 13 15 5
 2
 1 3
 3 1
 | 
5 319 8 6
 7 13 16
 8 4 11
 5 20 20
 20 5 14
 3
 3 2
 2 3
 2 5
 |  
| Sample Output I | Sample Output II |  | 
5 7 177 9 9
 6 11 12
 13 14 15
 | 
5 6 78 8 16
 11 4 13
 14 19 20
 20 5 20
 |  
 Для отправки решений необходимо выполнить вход.
 
 
 |