#include<map>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int x[200],y[200],z[200],m,n;
  int sm;
  char s[3];
  map<pair<pair<int,int>,int>,int> a;
  while(cin>>n>>m&&n+m){
    sm=n*n*n-n*m;
    for(i=0;i<m;i++){
      cin>>s;
      if(0){
      }else if(strcmp(s,"xy")==0){
	cin>>x[i]>>y[i];
	z[i]=0;
      }else if(strcmp(s,"xz")==0){
	cin>>x[i]>>z[i];
	y[i]=0;
      }else if(strcmp(s,"yz")==0){
	cin>>y[i]>>z[i];
	x[i]=0;
      }
      a.clear();
      for(j=0;j<i;j++){
	if(0){
	}else if(!x[i]&&!y[j]){
	  if(z[i]==z[j])
	    a[make_pair(make_pair(x[j],y[i]),z[i])]=1;
	}else if(!x[i]&&!z[j]){
	  if(y[i]==y[j])
	    a[make_pair(make_pair(x[j],y[i]),z[i])]=1;
	}else if(!y[i]&&!z[j]){
	  if(x[i]==x[j])
	    a[make_pair(make_pair(x[i],y[j]),z[i])]=1;
	}else if(!x[j]&&!y[i]){
	  if(z[i]==z[j])
	    a[make_pair(make_pair(x[i],y[j]),z[i])]=1;
	}else if(!x[j]&&!z[i]){
	  if(y[i]==y[j])
	    a[make_pair(make_pair(x[i],y[i]),z[j])]=1;
	}else if(!y[j]&&!z[i]){
	  if(x[i]==x[j])
	    a[make_pair(make_pair(x[i],y[i]),z[j])]=1;
	}
      }
      sm+=a.size();
    }
    cout<<sm<<endl;
  }
  return 0;
}