#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
vector<ll> ans_vec(500,0);
ll H,W,A,B;

void dfs(ll a,ll k,ll board[]){
    if(k == A){
        ans_vec[a]++;
    }
    for(ll h=0;h<H;h++){
        for(ll w=0;w<W;w++){
            if(k < a){
                if(w == W-1)
                    continue;
                if(board[h*H+w] == 1 || board[h*H+w+1] == 1)
                    continue;
                ll copy_board[500];
                rep(i,500)
                    copy_board[i] = board[i];
                copy_board[h*H+w] = 1;
                copy_board[h*H+w+1] = 1;
                dfs(a,k+1,copy_board);
            }
            else{
                if(h == H-1)
                    continue;
                if(board[h*H+w] == 1 || board[h*H+w+H] == 1)
                    continue;
                ll copy_board[500];
                rep(i,500)
                    copy_board[i] = board[i];
                copy_board[h*H+w] = 1;
                copy_board[h*H+w+H] = 1;
                dfs(a,k+1,copy_board);
            }
        }
    }
}

ll frac(ll a){
    if(a == 0)
        return 1;
    else
        return a*frac(a-1);
}


int main(){
    ll ans = 0;
    cin >> H >> W >> A >> B;
    if(H < W){
        ll tmp = W;
        W = H;
        H = tmp;
    }

    //0...縦 1...横

    for(ll a = 0; a <= A; a++){
        ll board[500];
        memset(board,0,sizeof(board));
        dfs(a,0,board);
    }
    for(ll a = 0; a <= A;a++){
        ans += ans_vec[a]/(frac(a)*frac(A-a));
    }
    cout << ans << endl;
}



#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N; 
  vector<vector<int>> vec(N, vector<int>(3));
  for(int i = 0; i < N; i++){
    cin >> vec[i][0] >> vec[i][1] >> vec[i][2];
  }
  long long answer = 0;
  for(int i = 0; i < N; i++){
    for(int j = i+1; j < N; j++){
      if((vec[i][1] < vec[j][1] && vec[j][1] < vec[i][2]) || (vec[j][1] < vec[i][1] && vec[i][1] < vec[j][2])){
        answer++;
      }
      else if(vec[j][2] == vec[i][1]){
        if((vec[j][0] == 1 || vec[j][0] == 3) && (vec[i][0] == 1 || vec[i][0] == 2)){
          answer++; 
        }
      }
      else if(vec[i][2] == vec[j][1]){
        if((vec[i][0] == 1 || vec[i][0] == 3) && (vec[j][0] == 1 || vec[j][0] == 2)){
          answer++; 
        }
      }
      else if(vec[i][1] == vec[j][1] || vec[i][2] == vec[j][2]){
        answer ++;
      }
    }
  }
  cout << answer << endl;
}