#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
const int N = 55;
const int M = 2505;
void print() { cout << "That's OK!" << endl; }
int tim[3], cnt[3], n, T, t[N], g[N];
long long tot[N][N][N][3], a[N][M], bc[N][N][M], ans = 0;
long long f(int x) {
  long long ret = 1;
  while (x > 1) ret = ret * x % MOD, x--;
  return ret % MOD;
}
long long F(int A, int B, int C) {
  long long ret = f(A) * f(B) % MOD * f(C) % MOD;
  ret = ret * (tot[A][B][C][0] + tot[A][B][C][1] + tot[A][B][C][2]) % MOD;
  return ret;
}
void add(long long &x, long long y) {
  x += y;
  if (x > MOD) x -= MOD;
}
void init() {
  scanf("%d%d", &n, &T);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &t[i], &g[i]);
    g[i]--;
    tim[g[i]] += t[i];
    cnt[g[i]]++;
  }
}
void ready_a() {
  a[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    if (g[i] != 0) continue;
    for (int j = cnt[0]; j >= 1; j--) {
      for (int k = t[i]; k <= tim[0]; k++) add(a[j][k], a[j - 1][k - t[i]]);
    }
  }
}
void ready_bc() {
  bc[0][0][0] = 1;
  for (int i = 1; i <= n; i++) {
    if (g[i] == 0) continue;
    for (int j = cnt[1]; j >= 0; j--) {
      for (int k = cnt[2]; k >= 0; k--) {
        for (int r = t[i]; r <= tim[1] + tim[2]; r++) {
          if (g[i] == 1 && j > 0) add(bc[j][k][r], bc[j - 1][k][r - t[i]]);
          if (g[i] == 2 && k > 0) add(bc[j][k][r], bc[j][k - 1][r - t[i]]);
        }
      }
    }
  }
}
void ready_tot() {
  tot[1][0][0][0] = 1;
  tot[0][1][0][1] = 1;
  tot[0][0][1][2] = 1;
  for (int i = 0; i <= cnt[0]; i++) {
    for (int j = 0; j <= cnt[1]; j++) {
      for (int k = 0; k <= cnt[2]; k++) {
        if (i > 0) {
          add(tot[i][j][k][0], tot[i - 1][j][k][1]);
          add(tot[i][j][k][0], tot[i - 1][j][k][2]);
        }
        if (j > 0) {
          add(tot[i][j][k][1], tot[i][j - 1][k][0]);
          add(tot[i][j][k][1], tot[i][j - 1][k][2]);
        }
        if (k > 0) {
          add(tot[i][j][k][2], tot[i][j][k - 1][0]);
          add(tot[i][j][k][2], tot[i][j][k - 1][1]);
        }
      }
    }
  }
}
void Test(int i, int j, int k, int val0, int val12) {
  cout << i << " " << j << " " << k << " " << val0 << " " << val12 << ":"
       << endl;
  printf("a[%d][%d]=%lld\n", i, val0, a[i][val0]);
  printf("bc[%d][%d][%d]=%lld\n", j, k, val12, bc[j][k][val12]);
  for (int lst = 0; lst <= 2; lst++) {
    printf("tot[%d][%d][%d][%d]=%lld   ", i, j, k, lst, tot[i][j][k][lst]);
  }
  puts("");
}
void solve() {
  ready_a();
  ready_bc();
  ready_tot();
  for (int i = 0; i <= cnt[0]; i++) {
    for (int j = 0; j <= cnt[1]; j++) {
      for (int k = 0; k <= cnt[2]; k++) {
        for (int val0 = 0; val0 <= tim[0]; val0++) {
          int val12 = T - val0;
          add(ans, F(i, j, k) * a[i][val0] % MOD * bc[j][k][val12] % MOD);
        }
      }
    }
  }
  cout << ans << endl;
}
int main() {
  init();
  solve();
  return 0;
}
