#include <cstdio>
#include <cstring>

using namespace std;

int n, m, k, p[1010][1010];

int main( void ) {

	scanf( "%d%d%d", &n, &k, &m );

	for( int i = 0; i < n; ++i ) {
		for( int j = 0; j < n; ++j ) {
			p[i][j] = 1;
		}
	}

	for( int i = 0; i < m; ++i ) {
		char s[100];
		scanf( "%s", s );
		if( strcmp( s, "PAINT" ) == 0 ) {
			int b, x1, y1, x2, y2;
			scanf( "%d%d%d%d%d", &b, &x1, &y1, &x2, &y2 );
			for( int j = x1; j <= x2; j += 2 ) {
				for( int h = y1; h <= y2; h += 2 ) {
					p[j][h] = b;
				}
				if( j + 1 > x2 ) continue;
				for( int h = y1+1; h <= y2; h += 2 ) {
					p[j+1][h] = b;
				}
			}
		}
	}

	for( int i = 0; i < n; ++i ) {
		for( int j = 0; j < n; ++j ) {
			printf( "%d ", p[i][j] );
		}
		printf( "\n" );
	}


    return 0;
}
