#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
const int maxx = 2510;
const long long mod = 1e9 + 7;
int n, T;
long long dp[maxn][maxn][maxn][4], sum[maxn][maxn][maxn];
long long way[maxx][maxn][4], fac[maxn], ans = 0;
int b[4];
vector<int> a[4];
void init() {
  dp[1][0][0][1] = 1;
  dp[0][1][0][2] = 1;
  dp[0][0][1][3] = 1;
  sum[1][0][0] = 1;
  sum[0][1][0] = 1;
  sum[0][0][1] = 1;
  fac[0] = 1;
  for (int i = 0; i <= n; i++) {
    if (i) fac[i] = 1ll * fac[i - 1] * i % mod;
    b[1] = i;
    for (int j = 0; j <= n - i; j++) {
      b[2] = j;
      for (int k = 0; k <= n - i - j; k++) {
        b[3] = k;
        if (i + j + k == 1) continue;
        for (int t = 1; t < 4; t++) {
          if (b[t] == 0) continue;
          b[t]--;
          dp[i][j][k][t] =
              (mod + sum[b[1]][b[2]][b[3]] - dp[b[1]][b[2]][b[3]][t]) % mod;
          b[t]++;
          sum[i][j][k] += dp[i][j][k][t];
          sum[i][j][k] %= mod;
        }
      }
    }
  }
  for (int t = 1; t < 4; t++) {
    way[0][0][t] = 1;
    for (int i = 0; i < a[t].size(); i++) {
      for (int j = maxx - 1; j >= a[t][i]; j--) {
        for (int k = 1; k <= i + 1; k++)
          way[j][k][t] = (way[j][k][t] + way[j - a[t][i]][k - 1][t]) % mod;
      }
    }
  }
}
void solve(int i, int j, int k) {
  for (int ii = 0; ii <= a[1].size(); ii++) {
    if (way[i][ii][1] == 0) continue;
    for (int jj = 0; jj <= a[2].size(); jj++) {
      if (way[j][jj][2] == 0) continue;
      for (int kk = 0; kk <= a[3].size(); kk++) {
        if (way[k][kk][3] == 0) continue;
        long long tmp =
            way[i][ii][1] * way[j][jj][2] % mod * way[k][kk][3] % mod;
        long long tmp2 = fac[ii] * fac[jj] % mod * fac[kk] % mod;
        long long tmp3 = sum[ii][jj][kk];
        ans = (ans + tmp * tmp2 % mod * tmp3 % mod) % mod;
      }
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n >> T;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a[y].push_back(x);
  }
  init();
  for (int i = 0; i <= T; i++) {
    for (int j = 0; j <= T - i; j++) {
      int k = T - i - j;
      solve(i, j, k);
    }
  }
  cout << ans << "\n";
  return 0;
}
