#include <bits/stdc++.h>
using namespace std;
inline int getint() {
  int num = 0, flag = 1;
  char c;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flag = -1;
  while (c >= '0' && c <= '9') num = num * 10 + c - 48, c = getchar();
  return num * flag;
}
int n, m;
int g[55][55][55][3];
int h[55][55][55], fac[55];
int f[3][55][55 * 55], d[55][55][55 * 55];
int sum[55];
vector<int> V[3];
inline void upd(int &x, int y) {
  x = (x + y < 1000000007 ? x + y : x + y - 1000000007);
}
inline void init(int n) {
  g[0][0][1][2] = g[0][1][0][1] = g[1][0][0][0] = fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = 1ll * fac[i - 1] * i % 1000000007;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++)
      for (int k = 0; k <= n; k++)
        for (int p = 0; p <= 2; p++)
          if (g[i][j][k][p]) {
            if (p != 0) upd(g[i + 1][j][k][0], g[i][j][k][p]);
            if (p != 1) upd(g[i][j + 1][k][1], g[i][j][k][p]);
            if (p != 2) upd(g[i][j][k + 1][2], g[i][j][k][p]);
            upd(h[i][j][k], 1ll * fac[i] * fac[j] % 1000000007 * fac[k] %
                                1000000007 * g[i][j][k][p] % 1000000007);
          }
}
int main() {
  init(50);
  n = getint(), m = getint();
  for (int i = 1; i <= n; i++) {
    int t = getint(), g = getint() - 1;
    sum[g] += t, V[g].push_back(t);
  }
  if (sum[0] > sum[2]) swap(sum[0], sum[2]), swap(V[0], V[2]);
  if (sum[1] > sum[2]) swap(sum[1], sum[2]), swap(V[1], V[2]);
  for (int p = 0; p <= 2; p++) {
    f[p][0][0] = 1;
    for (int i = 0; i < V[p].size(); i++)
      for (int j = i + 1; j; j--)
        for (int k = sum[p]; k >= V[p][i]; k--)
          upd(f[p][j][k], f[p][j - 1][k - V[p][i]]);
  }
  for (int u = 0; u <= V[0].size(); u++)
    for (int j = 0; j <= sum[0]; j++)
      if (f[0][u][j])
        for (int i = 0; i <= V[1].size(); i++)
          for (int k = 0; k <= sum[1]; k++)
            if (f[1][i][k])
              upd(d[u][i][j + k], 1ll * f[0][u][j] * f[1][i][k] % 1000000007);
  int ans = 0;
  for (int u = 0; u <= V[2].size(); u++)
    for (int i = 0; i <= sum[2]; i++)
      if (f[2][u][i])
        for (int j = 0; j <= V[0].size(); j++)
          for (int k = 0; k <= V[1].size(); k++)
            upd(ans, 1ll * h[u][j][k] * d[j][k][m - i] % 1000000007 *
                         f[2][u][i] % 1000000007);
  printf("%d\n", ans);
}
