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

typedef pair<int,int>xy;
typedef pair<xy,int>xyz;

#define X first.first
#define Y first.second
#define Z second


int main(){
	int n,h;
	while(cin>>n>>h,(n+h)){
		map<xyz,int>MP;
		int ans=n*n*n;
		
		string s;
		int a,b;
		for(int i=0;i<h;i++){
			cin>>s>>a>>b;
			int A,B,C;
			for(int i=1;i<=n;i++){
				if(s=="xy"){
					A=a;
					B=b;
					C=i;
				}
				if(s=="xz"){
					A=a;
					B=i;
					C=b;
				}
				if(s=="yz"){
					A=i;
					B=a;
					C=b;
				}
				
				if(MP[xyz(xy(A,B),C)]==0){
					ans--;
					MP[xyz(xy(A,B),C)]=1;
				}
				
			}
		}
		
		cout<<ans<<endl;
	}
	
	
	return 0;
}
