#include <bits/stdc++.h>
using namespace std;
int n, T;
int ti[52], gi[52], fact[52];
int dp[52][52][52][3], sz[3], p[3];
int get_dp(int ca, int cb, int cc, int lst) {
  if (ca < 0 || cb < 0 || cc < 0) {
    return 0;
  } else if (ca == 0 && cb == 0 && cc == 0) {
    return 1;
  } else if (dp[ca][cb][cc][lst] != -1) {
    return dp[ca][cb][cc][lst];
  } else {
    long long v1 = 1LL * get_dp(ca - 1, cb, cc, 0) * (lst != 0);
    long long v2 = 1LL * get_dp(ca, cb - 1, cc, 1) * (lst != 1);
    long long v3 = 1LL * get_dp(ca, cb, cc - 1, 2) * (lst != 2);
    return dp[ca][cb][cc][lst] =
               ((v1 + v2) % ((long long)1e9 + 7) + v3) % ((long long)1e9 + 7);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  fact[0] = 1;
  cin >> n >> T;
  for (int i = 0; i < n; ++i) {
    cin >> ti[i] >> gi[i];
    ++sz[--gi[i]];
    fact[i + 1] = (1LL * fact[i] * (i + 1LL)) % ((long long)1e9 + 7);
  }
  int dp2[2][2505][sz[0] + 1][sz[1] + 1][sz[2] + 1];
  memset(dp, 255, sizeof(dp));
  memset(dp2, 0, sizeof(dp2));
  dp2[0][0][0][0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int t = 0; t <= T; ++t) {
      for (p[0] = 0; p[0] <= sz[0]; ++p[0]) {
        for (p[1] = 0; p[1] <= sz[1]; ++p[1]) {
          for (p[2] = 0; p[2] <= sz[2]; ++p[2]) {
            int v = dp2[1 - (i & 1)][t][p[0]][p[1]][p[2]];
            for (int k = 0; k < 3; ++k) {
              if (t < ti[i - 1] || gi[i - 1] != k || p[k] == 0) continue;
              --p[k];
              v = (v + dp2[1 - (i & 1)][t - ti[i - 1]][p[0]][p[1]][p[2]]) %
                  ((long long)1e9 + 7);
              ++p[k];
            }
            dp2[i & 1][t][p[0]][p[1]][p[2]] = v;
          }
        }
      }
    }
  }
  int ans = 0;
  for (p[0] = 0; p[0] <= sz[0]; ++p[0]) {
    for (p[1] = 0; p[1] <= sz[1]; ++p[1]) {
      for (p[2] = 0; p[2] <= sz[2]; ++p[2]) {
        int v1 = 0, v2 = 1;
        for (int k = 0; k < 3; ++k) {
          v2 = (1LL * v2 * fact[p[k]]) % ((long long)1e9 + 7);
          if (!p[k]) continue;
          --p[k];
          v1 = (1LL * v1 + get_dp(p[0], p[1], p[2], k)) % ((long long)1e9 + 7);
          ++p[k];
        }
        int curr = ((1LL * dp2[n & 1][T][p[0]][p[1]][p[2]] * v1) %
                    ((long long)1e9 + 7) * v2) %
                   ((long long)1e9 + 7);
        ans = (ans + curr) % ((long long)1e9 + 7);
      }
    }
  }
  cout << ans << "\n";
}
