#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, T, g[55], t[55], sz[5];
long long ans, G[55][2555], dp[55][55][2555], f[55][55][55][4], js[55];
int main() {
  cin >> n >> T;
  for (int i = js[0] = 1; i <= n; ++i) js[i] = js[i - 1] * i % mod;
  for (int i = 1; i <= n; ++i) cin >> t[i] >> g[i];
  dp[0][0][0] = 1;
  for (int i = 1; i <= n; ++i)
    if (g[i] == 1 || g[i] == 2) {
      for (int j = sz[1]; ~j; --j)
        for (int k = sz[2]; ~k; --k)
          for (int s = T; s >= t[i]; --s)
            if (g[i] == 1)
              (dp[j + 1][k][s] += dp[j][k][s - t[i]]) %= mod;
            else
              (dp[j][k + 1][s] += dp[j][k][s - t[i]]) %= mod;
      sz[g[i]]++;
    }
  G[0][0] = 1;
  for (int i = 1; i <= n; ++i)
    if (g[i] == 3) {
      for (int j = sz[3]; ~j; --j)
        for (int s = T; s >= t[i]; --s) (G[j + 1][s] += G[j][s - t[i]]) %= mod;
      sz[3]++;
    }
  f[0][0][0][0] = 1;
  for (int i = 0; i <= sz[1]; ++i)
    for (int j = 0; j <= sz[2]; ++j)
      for (int k = 0; k <= sz[3]; ++k)
        for (int s = 0; s <= 3; ++s)
          for (int t = 1; t <= 3; ++t)
            if (s != t)
              (f[i + (t == 1)][j + (t == 2)][k + (t == 3)][t] +=
               f[i][j][k][s]) %= mod;
  for (int i = 0; i <= sz[1]; ++i)
    for (int j = 0; j <= sz[2]; ++j)
      for (int k = 0; k <= sz[3]; ++k)
        for (int t = 0; t <= T; ++t)
          (ans +=
           dp[i][j][t] * G[k][T - t] % mod *
           (f[i][j][k][0] + f[i][j][k][1] + f[i][j][k][2] + f[i][j][k][3]) %
           mod * js[i] % mod * js[j] % mod * js[k]) %= mod;
  cout << ans << endl;
  return 0;
}
