#include <cstdlib>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
int *output;
int *colors;
size_t width;
size_t height;
size_t color_count;
void draw_vertical(size_t x, int color) {
for (size_t i = 0; i < height; i++) {
colors[output[i * width + x]]--;
colors[color]++;
output[i * width + x] = color;
}
}
void draw_horizontal(size_t y, int color) {
for (size_t i = 0; i < width; i++) {
colors[output[i * width + x]]--;
colors[color]++;
output[y * width + i] = color;
}
}
int main(void) {
char *input = (char *)malloc(1024*1024*32);
size_t len = read(0, input, 1024*1024*32);
char *ptr = input;
size_t next_space = strchr(input, ' ') - input;
input[next_space] = '\0';
height = atoi(input);
ptr += next_space + 1;
next_space = strchr(ptr, ' ') - ptr;
ptr[next_space] = '\0';
width = atoi(ptr);
ptr += next_space + 1;
next_space = strchr(ptr, ' ') - ptr;
ptr[next_space] = '\0';
color_count = atoi(ptr);
ptr += next_space + 1;
next_space = strchr(ptr, ' ') - ptr;
ptr[next_space] = '\0';
size_t operations = atoi(ptr);
ptr += next_space + 1;
colors = (int *)malloc(color_count * sizeof(int) + sizeof(int));
output = (int *)malloc(height * width * sizeof(int));
for (size_t i = 0; i < operations; i++) {
int rc = ptr[0];
ptr += 2;
next_space = strchr(ptr, ' ') - ptr;
ptr[next_space] = '\0';
size_t n = atoi(ptr);
ptr += next_space + 1;
next_space = strchr(ptr, '\n') - ptr;
ptr[next_space] = '\0';
size_t color = atoi(ptr);
ptr += next_space + 1;
if (rc == 'R') {
draw_vertical(n, color);
} else {
draw_horizontal(n, color);
}
}
for (size_t i = 0; i < color_count + 1; i++) {
printf("%d ", colors[i]);
}
free(input);
free(colors);
free(output);
}