#include <bits/stdc++.h>
using namespace std;
namespace fastIO {
bool IOerror = 0;
inline char nc() {
  static char buf[100000], *p1 = buf + 100000, *pend = buf + 100000;
  if (p1 == pend) {
    p1 = buf;
    pend = buf + fread(buf, 1, 100000, stdin);
    if (pend == p1) {
      IOerror = 1;
      return -1;
    }
  }
  return *p1++;
}
inline bool blank(char ch) {
  return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
}
inline long long read() {
  bool sign = 0;
  char ch = nc();
  long long x = 0;
  for (; blank(ch); ch = nc())
    ;
  if (IOerror) return 0;
  if (ch == '-') sign = 1, ch = nc();
  for (; ch >= '0' && ch <= '9'; ch = nc()) x = x * 10 + ch - '0';
  if (sign) x = -x;
  return x;
}
};  // namespace fastIO
using namespace fastIO;
long long g[60][60][60][4], fac[1000010], t[1000010], tp[1000010], num[10],
    f1[60][60][3000], f2[60][3000], f[60][60][60];
signed main() {
  long long n = read(), T = read();
  for (long long i = 1; i <= n; i++) {
    t[i] = read(), tp[i] = read();
    num[tp[i]]++;
  }
  fac[0] = 1;
  for (long long i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % 1000000007;
  g[1][0][0][1] = g[0][1][0][2] = g[0][0][1][3] = 1;
  for (long long i = 0; i <= num[1]; i++) {
    for (long long j = 0; j <= num[2]; j++) {
      for (long long k = 0; k <= num[3]; k++) {
        g[i + 1][j][k][1] += g[i][j][k][2] + g[i][j][k][3];
        g[i][j + 1][k][2] += g[i][j][k][1] + g[i][j][k][3];
        g[i][j][k + 1][3] += g[i][j][k][1] + g[i][j][k][2];
        g[i + 1][j][k][1] %= 1000000007, g[i][j + 1][k][2] %= 1000000007,
            g[i][j][k + 1][3] %= 1000000007;
        f[i][j][k] =
            (g[i][j][k][1] + g[i][j][k][2] + g[i][j][k][3]) % 1000000007 *
            (fac[i] * fac[j] % 1000000007 * fac[k] % 1000000007) % 1000000007;
      }
    }
  }
  f1[0][0][0] = 1;
  for (long long i = 1; i <= n; i++) {
    if (tp[i] == 3) continue;
    for (long long j = num[1]; j >= 0; j--) {
      for (long long k = num[2]; k >= 0; k--) {
        for (long long w = T - t[i]; w >= 0; w--) {
          f1[j + (tp[i] == 1)][k + (tp[i] == 2)][w + t[i]] += f1[j][k][w],
              f1[j + (tp[i] == 1)][k + (tp[i] == 2)][w + t[i]] %= 1000000007;
        }
      }
    }
  }
  f2[0][0] = 1;
  for (long long i = 1; i <= n; i++) {
    if (tp[i] != 3) continue;
    for (long long j = num[3]; j >= 0; j--) {
      for (long long w = T - t[i]; w >= 0; w--) {
        f2[j + 1][w + t[i]] += f2[j][w], f2[j + 1][w + t[i]] %= 1000000007;
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i <= num[1]; i++) {
    for (long long j = 0; j <= num[2]; j++) {
      for (long long k = 0; k <= num[3]; k++) {
        for (long long w = 0; w <= T; w++) {
          ans += f1[i][j][w] * f2[k][T - w] % 1000000007 * f[i][j][k],
              ans %= 1000000007;
        }
      }
    }
  }
  cout << ans;
  return 0;
}
