/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
int time = t.nextInt();
int score = t.nextInt();
while(time<90) {
score++;
time += 5;
}
System.out.printf("%d\n", score);
}
}
*/
/*
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
int[] n = new int[3];
for(int i=0; i<3; i++) {
n[i] = t.nextInt();
}
for(int i=0; i<3; i++) {
for(int j=0; j<2; j++) {
if(n[j] > n[j+1]) {
int temp = n[j];
n[j] = n[j+1];
n[j+1] = temp;
}
}
}
System.out.printf("%d\n", n[1]);
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
int n = t.nextInt();
int b = t.nextInt();
n /= 10000;
if(b <= 2) {
System.out.print(112-n+1);
}
else {
System.out.print(12-n+1);
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
int h = t.nextInt();
int m = t.nextInt();
if(m < 30) {
if(h==0) {
System.out.println((23)+" "+(60-(30-m)));
}
else {
System.out.println((h-1)+" "+(60-(30-m)));
}
}
else {
System.out.println(h+" "+(m-30));
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
int n = t.nextInt();
n = (((n%10)*10 + (n/10))*2)%100;
System.out.println(n);
if(n > 50) {
System.out.println("OH MY GOD");
}
else {
System.out.println("GOOD");
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
int[] a = new int[3];
for(int i=0; i<3; i++) {
a[i] = t.nextInt();
}
for(int i=0; i<3; i++) {
for(int j=0; j<2; j++) {
if(a[j] > a[j+1]) {
int temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
if(a[0]+a[1] <= a[2]) {
System.out.println("삼각형아님");
}
else if(a[0]==a[1] && a[1]==a[2]) {
System.out.println("정삼각형");
}
else if(a[0]==a[1] || a[1]==a[2] || a[2]==a[0]) {
System.out.println("이등변삼각형");
}
else if((a[0]*a[0]) + (a[1]*a[1]) == a[2]*a[2]) {
System.out.println("직각삼각형");
}
else {
System.out.println("삼각형");
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
int n = t.nextInt();
int a=0;
for(int i=2; i<n/2; i++) {
if(n%i==0) {
for(int j=2; j<i; j++) {
if(i%j==0) {
a=1;
}
}
for(int j=2; j<(n/i); j++) {
if((n/i)%j==0) {
a=1;
}
}
if(a==1) {
a=0;
}
else {
System.out.println(i+" "+n/i);
a=1;
break;
}
}
}
if(a==0) {
System.out.println("wrong number");
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
double n = t.nextDouble();
int a = t.nextInt();
int[] arr = new int[a];
for(int i=0; i<a; i++) {
arr[i] = t.nextInt();
}
double n1 = n;
for(int i=0; i<a; i++) {
n1 += (n1/100)*arr[i];
}
System.out.printf("%.0f\n", n1-n);
if(n1-n==0) {
System.out.println("same");
}
else if(n1-n>0) {
System.out.println("good");
}
else {
System.out.println("bad");
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
int n = t.nextInt();
int k = t.nextInt();
int[] k1 = new int[n*2];
for(int i=0; i<n*2; i++) {
k1[i] = k*(i+1);
}
for(int i=0; i<n; i++) {
for(int l=0; l<n*2; l++) {
k1[l] -= 1;
//System.out.println(i+" "+k1[l]);
}
for(int j=0; j<n; j++) {
int a=0;
for(int l=0; l<n*2; l++) {
if(j==k1[l]) {
a=1;
}
}
if(i==0 || i==n-1 || j==0 || j==n-1 || a==1) {
System.out.print("*");
}
else {
System.out.print(" ");
}
}
System.out.println("");
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
int n = t.nextInt();
int[] arr = new int[10000001];
for(int i=0; i<n; i++) {
arr[t.nextInt()] = 1;
}
int m = t.nextInt();
for(int i=0; i<m; i++) {
System.out.print(arr[t.nextInt()]+" ");
}
}
}
1405
1411
1416
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
int n = t.nextInt();
int[] arr = new int[n];
for(int i=0; i<n; i++) {
arr[i] = t.nextInt();
}
for(int i=0; i<n; i++) {
for(int j=0; j<n; j++) {
int a = j+i;
if(a >= n) {
a -= n;
}
System.out.print(arr[a] + " ");
}
System.out.println("");
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
int n = t.nextInt();
int[] c = new int[n+1];
for(int i=0; i<n-1; i++) {
c[t.nextInt()] = 1;
}
for(int i=1; i<=n; i++) {
if(c[i]==0) {
System.out.println(i);
}
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
int n = t.nextInt();
int[] arr = new int[32];
int a=0;
while(n>=2) {
arr[a] = n%2;
n/=2;
a++;
}
arr[a] = n;
for(int i=a; i>=0; i--) {
System.out.print(arr[i]);
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
int[][] map = new int[27][27];
int[][] map1 = new int[27][27];
for(int i=1; i<=25; i++) {
for(int j=1; j<=25; j++) {
map[i][j] = t.nextInt();
}
}
for(int i=1; i<=25; i++) {
for(int j=1; j<=25; j++) {
if(map[i][j]==0) {
int n=0;
for(int k=i-1; k<=i+1; k++) {
for(int l=j-1; l<=j+1; l++) {
if(map[k][l]==1) {
n++;
}
}
}
if(n==3) {
map1[i][j] = 1;
}
}
else {
int n=0;
for(int k=i-1; k<=i+1; k++) {
for(int l=j-1; l<=j+1; l++) {
int a=0;
if(i==k && j==l) {
a=1;
}
if(map[k][l]==1 && a != 1) {
n++;
}
}
}
if(n==2 || n==3) {
map1[i][j] = 1;
}
}
}
}
for(int i=1; i<=25; i++) {
for(int j=1; j<=25; j++) {
System.out.print(map1[i][j]+" ");
}
System.out.println("");
}
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
int a = t.nextInt();
int b = t.nextInt();
int x = t.nextInt(), y = t.nextInt(), z = t.nextInt();
int[][] map = new int[a+2][b+2];
int[][] map1 = new int[a+2][b+2];
for(int i=1; i<=a; i++) {
for(int j=1; j<=b; j++) {
map[i][j] = t.nextInt();
}
}
int k = t.nextInt();
int t1=0;
for(int i=0; i<k; i++) {
if(i%2==0) {
for(int j=1; j<=a; j++) {
for(int l=1; l<=b; l++) {
if(map[j][l]==0) {
int n1=0;
for(int m=j-1; m<=j+1; m++) {
for(int n=l-1; n<=l+1; n++) {
if(map[m][n]==1) {
n1++;
}
}
}
if(n1==x) {
map1[j][l]=1;
}
else {
map1[j][l]=0;
}
}
else {
int n1=0;
for(int m=j-1; m<=j+1; m++) {
for(int n=l-1; n<=l+1; n++) {
if(map[m][n]==1) {
n1++;
}
}
}
n1--;
if(n1 >= y && n1 < z) {
map1[j][l] = 1;
}
else {
map1[j][l] = 0;
}
}
}
}
t1=1;
}
else {
for(int j=1; j<=a; j++) {
for(int l=1; l<=b; l++) {
if(map1[j][l]==0) {
int n1=0;
for(int m=j-1; m<=j+1; m++) {
for(int n=l-1; n<=l+1; n++) {
if(map1[m][n]==1) {
n1++;
}
}
}
if(n1==x) {
map[j][l]=1;
}
else {
map[j][l]=0;
}
}
else {
int n1=0;
for(int m=j-1; m<=j+1; m++) {
for(int n=l-1; n<=l+1; n++) {
if(map1[m][n]==1) {
n1++;
}
}
}
n1--;
if(n1 >= y && n1 < z) {
map[j][l] = 1;
}
else {
map[j][l] = 0;
}
}
}
}
t1=0;
}
}
if(t1==1) {
for(int i=1; i<=a; i++) {
for(int j=1; j<=b; j++) {
System.out.print(map1[i][j]+" ");
}
System.out.println("");
}
}
else {
for(int i=1; i<=a; i++) {
for(int j=1; j<=b; j++) {
System.out.print(map[i][j]+" ");
}
System.out.println("");
}
}
}
}
*/
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
int w = t.nextInt(), h = t.nextInt();
int[][] map = new int[h+2][w+2];
int n = t.nextInt();
int[] d = new int[n], l = new int[n];
int[] x = new int[n], y = new int[n];
for(int i=0; i<n; i++) {
l[i] = t.nextInt();
d[i] = t.nextInt();
x[i] = t.nextInt();
y[i] = t.nextInt();
}
for(int i=0; i<n; i++) {
if(d[i]==0) {
for(int j=0; j<l[i]; j++) {
map[y[i]][x[i]+j]=1;
}
}
if(d[i]==1) {
for(int j=0; j<l[i]; j++) {
System.out.println(i+" "+j+" "+x[i]+" "+(y[i]+j));
map[y[i]+j][x[i]]=1;
}
}
}
for(int i=1; i<=h; i++) {
for(int j=1; j<=w; j++) {
System.out.print(map[i][j]+" ");
}
System.out.println("");
}
}
}