#include <iostream>
#include <string>
#include <cstring>
#include <set>
using namespace std;


int main() {
  int n, h;
  while (cin >> n >> h, n+h) {
    set<int> cube;
    
    for (int i=0; i<h; i++) {
      string s;
      int a, b;
      cin >> s;
      cin >> a >> b;
      a--;b--;
      if (s == "xy") {
        for (int j=0; j<n; j++) {
          cube.insert(a*500*500+b*500+j);
        }
      } else if (s == "xz") {
        for (int j=0; j<n; j++) {
          cube.insert(a*500*500+j*500+b);
        }
      } else {
        for (int j=0; j<n; j++) {
          cube.insert(j*500*500+a*500+b);
        }
      }
    }
    cout << n*n*n-cube.size() << endl;
  }
}