#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
typedef pair< int, P > PP;

int main() {
  int N, H;
  while(cin >>N >>H && N){
    set<PP> S;
    REP(h, H){
      string s; int a, b; cin >>s >>a >>b;
      FOR(i, 1, N + 1){
        if(s == "xy") S.insert(PP(a, P(b, i)));
        if(s == "xz") S.insert(PP(a, P(i, b)));
        if(s == "yz") S.insert(PP(i, P(a, b)));
      }
    }
    cout <<N * N * N - S.size() <<endl;
  }
  return 0;
}