import std.stdio, std.string, std.conv, std.algorithm;

void main(){
    bool[201][201][201] cube;
    void init(){
        foreach(z; 0..201)
            foreach(y; 0..201)
                cube[z][y][] = false;
    }
    while(true){
        auto input = readln.split.map!(to!int);
        int h = input[0], n = input[1];
        if(n == 0 && h == 0) break;
        foreach(i; 0..n){
            auto line = readln.split;
            int a = line[1].to!int - 1, b = line[2].to!int - 1;
            final switch(line[0]){
                case "xy":
                    foreach(z; 0..h){
                        cube[a][b][z] = true;
                    }
                    break;
                case "xz":
                    foreach(y; 0..h){
                        cube[a][y][b] = true;
                    }
                    break;
                case "yz":
                    foreach(x; 0..h){
                        cube[x][a][b] = true;
                    }
                    break;
            }
        }
        int count;
        foreach(z; 0..h){
            foreach(y; 0..h){
                foreach(x; 0..h){
                    if(!cube[x][y][z]) ++count;
                }
            }
        }
        count.writeln;
        init();
    }
}