#include <bits/stdc++.h>
using namespace std;
const int maxn = 55, maxs = 2550, mod = 1e9 + 7;
const long long inf = 1e18;
int dp[2][maxn][maxn][maxs], ddp[2][maxn][maxs];
int dp2[maxn][maxn][maxn][3], sm[maxn][maxn][maxn];
inline void add(int &a, int b) { a = (a + b) % mod; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, t;
  cin >> n >> t;
  dp[0][0][0][0] = 1;
  ddp[0][0][0] = 1;
  for (int w = 1; w <= n; w++) {
    int o = w & 1, O = 1 - o;
    int a, b;
    cin >> a >> b;
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= n; j++) {
        for (int sm = 0; sm <= t; sm++) {
          dp[o][i][j][sm] = dp[O][i][j][sm];
          if (b == 1 && i && sm >= a)
            add(dp[o][i][j][sm], dp[O][i - 1][j][sm - a]);
          if (b == 2 && j && sm >= a)
            add(dp[o][i][j][sm], dp[O][i][j - 1][sm - a]);
        }
      }
    }
    for (int k = 0; k <= n; k++) {
      for (int sm = 0; sm <= t; sm++) {
        ddp[o][k][sm] = ddp[O][k][sm];
        if (b == 3 && k && sm >= a) add(ddp[o][k][sm], ddp[O][k - 1][sm - a]);
      }
    }
  }
  sm[0][0][0] = 1;
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k <= n; k++) {
        if (i + j + k <= 1) {
          dp2[1][0][0][0] = 1;
          dp2[0][1][0][1] = 1;
          dp2[0][0][1][2] = 1;
        } else {
          if (i)
            dp2[i][j][k][0] =
                1ll * i * (sm[i - 1][j][k] - dp2[i - 1][j][k][0]) % mod;
          if (j)
            dp2[i][j][k][1] =
                1ll * j * (sm[i][j - 1][k] - dp2[i][j - 1][k][1]) % mod;
          if (k)
            dp2[i][j][k][2] =
                1ll * k * (sm[i][j][k - 1] - dp2[i][j][k - 1][2]) % mod;
        }
        for (int w = 0; w < 3; w++) {
          add(sm[i][j][k], dp2[i][j][k][w]);
        }
        long long num = 0;
        for (int s = 0; s <= t; s++) {
          num += 1ll * dp[n & 1][i][j][s] * ddp[n & 1][k][t - s];
          if ((s & 7) == 0) num %= mod;
        }
        num %= mod;
        ans = (num * sm[i][j][k] + 1ll * ans) % mod;
      }
    }
  }
  if (ans < 0) ans += mod;
  return cout << ans << endl, 0;
}
