#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
vector<int> num[3];
long long dp[3][2505][55], fac[55];
bool have[3][2505];
long long C[3][55][55][55];
bool done[3][55][55][55];
int N, T;
long long cal(int t, int i, int j, int k) {
  if (done[t][i][j][k]) return C[t][i][j][k];
  done[t][i][j][k] = 1;
  long long& ans = C[t][i][j][k];
  if (t == 0) {
    if (i == 0) return ans = 0;
    return ans = (cal(1, i - 1, j, k) + cal(2, i - 1, j, k)) % mod;
  }
  if (t == 1) {
    if (j == 0) return ans = 0;
    return ans = (cal(0, i, j - 1, k) + cal(2, i, j - 1, k)) % mod;
  }
  if (t == 2) {
    if (k == 0) return ans = 0;
    return ans = (cal(0, i, j, k - 1) + cal(1, i, j, k - 1)) % mod;
  }
}
long long solve(int a, int b, int c) {
  if (!(have[0][a] && have[1][b] && have[2][c])) return 0;
  long long re = 0;
  for (int i = 0; i <= num[0].size(); i++) {
    if (!dp[0][a][i]) continue;
    for (int j = 0; j <= num[1].size(); j++) {
      if (!dp[1][b][j]) continue;
      for (int k = 0; k <= num[2].size(); k++) {
        if (!dp[2][c][k]) continue;
        long long tem = 0;
        tem = (tem + cal(0, i, j, k)) % mod;
        tem = (tem + cal(1, i, j, k)) % mod;
        tem = (tem + cal(2, i, j, k)) % mod;
        tem = tem * fac[i] % mod;
        tem = tem * fac[j] % mod;
        tem = tem * fac[k] % mod;
        tem = tem * dp[0][a][i] % mod;
        tem = tem * dp[1][b][j] % mod;
        tem = tem * dp[2][c][k] % mod;
        re = (re + tem) % mod;
      }
    }
  }
  return re;
}
void DP(int x) {
  have[x][0] = 1;
  dp[x][0][0] = 1;
  for (int i = 0; i < num[x].size(); i++) {
    for (int j = T; j >= num[x][i]; j--) {
      int t = num[x][i];
      if (have[x][j - t]) {
        for (int k = 1; k <= i + 1; k++) {
          dp[x][j][k] = (dp[x][j][k] + dp[x][j - t][k - 1]) % mod;
        }
        have[x][j] = 1;
      }
    }
  }
}
void init() {
  C[0][1][0][0] = C[1][0][1][0] = C[2][0][0][1] = 1;
  done[0][1][0][0] = done[1][0][1][0] = done[2][0][0][1] = 1;
  fac[0] = fac[1] = 1;
  for (int i = 2; i <= 50; i++) {
    fac[i] = i * fac[i - 1] % mod;
  }
}
int main() {
  init();
  scanf("%d%d", &N, &T);
  for (int i = 0; i < N; i++) {
    int t1, t2;
    scanf("%d%d", &t1, &t2);
    num[t2 - 1].push_back(t1);
  }
  for (int i = 0; i < 3; i++) {
    DP(i);
  }
  long long ans = 0;
  for (int i = 0; i <= T; i++) {
    for (int j = 0; j <= T; j++) {
      if (i + j > T) break;
      int k = T - i - j;
      ans += solve(i, j, k);
      ans %= mod;
    }
  }
  printf("%I64d\n", ans);
}
