#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<cctype>
#include<sstream>
using namespace std;
#define pii pair<int,int>
#define LL long long int
const int eps=1e-;
const int INF=;
const int maxp=+;
int n,m,k,p,p1,p2,ans;
int pants[];
struct Dis
{
char s1[],s2[];
int t1,t2;
} a[maxp];
int main()
{
//freopen("in10.txt","r",stdin);
//freopen("out.txt","w",stdout);
while(scanf("%d%d%d",&n,&m,&k)==)
{
if(n==&&m==&&k==) break;
ans=n*m*k;
p1=p2=;
memset(pants,,sizeof(pants));
scanf("%d",&p);
for(int i=; i<p; i++)
{
scanf("%s%d%s%d",a[i].s1,&a[i].t1,a[i].s2,&a[i].t2);
if(a[i].s1[]=='c') p1++;
else
{
p2++;
pants[a[i].t1]++;
}
}
ans-=(p1*k+p2*n);
for(int i=;i<p;i++)
{
if(a[i].s2[]=='p')
{
ans+=pants[a[i].t2];
}
}
printf("%d\n",ans);
}
//fclose(stdin);
//fclose(stdout);
return ;
}