#include <bits/stdc++.h>
using namespace std;
const int MOD = int(1E9) + 7;
inline int add(int x, int y) {
  x += y;
  return x >= MOD ? x - MOD : x;
}
inline int sub(int x, int y) {
  x -= y;
  return x < 0 ? x + MOD : x;
}
inline int mul(int x, int y) { return (int)(1LL * x * y % MOD); }
int mpow(int b, int p) {
  int r;
  for (r = 1; p; p >>= 1, b = mul(b, b))
    if (p & 1) r = mul(r, b);
  return r;
}
int h[55][55][55], fct[55];
void init(int n) {
  h[0][0][0] = fct[0] = 1;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n - i; j++)
      for (int k = 1; k <= i + j; k++)
        for (int p = 0; p <= i; p++) {
          if (p && p - 1 <= j)
            h[i][j][k] = add(h[i][j][k], h[i - p][j - (p - 1)][k - 1]);
          if (p && p <= j)
            h[i][j][k] = add(h[i][j][k], mul(h[i - p][j - p][k - 1], 2));
          if (p + 1 <= j)
            h[i][j][k] = add(h[i][j][k], h[i - p][j - (p + 1)][k - 1]);
        }
  for (int i = 1; i <= n; i++) fct[i] = mul(fct[i - 1], i);
}
int f[55][55][2505], p[55][2505], t[55], g[55];
int main() {
  int n, T;
  scanf("%d%d", &n, &T), init(n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &t[i], &g[i]);
  int c = 0, s = 0;
  p[0][0] = 1;
  for (int o = 1; o <= 3; o++) {
    for (int i = 0; i <= c; i++)
      for (int k = 0; k <= s; k++) f[i][0][k] = p[i][k], p[i][k] = 0;
    int b = 0;
    for (int x = 1; x <= n; x++)
      if (g[x] == o) {
        for (int i = 0; i <= c; i++)
          for (int j = b; j >= 0; j--)
            for (int k = 0; k <= min(s, T - t[x]); k++)
              if (f[i][j][k])
                f[i][j + 1][k + t[x]] = add(f[i][j + 1][k + t[x]], f[i][j][k]);
        b++, s += t[x];
      }
    for (int i = 0; i <= c; i++)
      for (int j = 0; j <= b; j++)
        for (int k = 0; k <= s; k++) f[i][j][k] = mul(f[i][j][k], fct[j]);
    for (int i = 0; i <= c; i++)
      for (int j = 0; j <= b; j++)
        for (int k = 0; k <= s; k++)
          if (f[i][j][k]) {
            for (int l = 0; l <= i + j; l++)
              p[l][k] = add(p[l][k], mul(f[i][j][k], h[i][j][l]));
            f[i][j][k] = 0;
          }
    c += b;
  }
  printf("%d\n", p[1][T]);
}
