#include using namespace std; int s[1000][1000]; int n,m,q; void fills(int a, int b) { for(int i=0;i>n>>m>>q; for(int i=0;i>s[i][j]; } } int x,y; for(int i=0;i>x>>y; fills(x-1,y-1); } for(int i=0;i