#include <bits/stdc++.h>
int dp[50 + 1][50 + 1][50 + 1], dq[50 + 1][50 + 1][50 + 1][3];
void init(int na, int nb, int nc) {
  int ma, mb, mc, x0, x1, x2;
  for (ma = 0; ma <= na; ma++)
    for (mb = 0; mb <= nb; mb++)
      for (mc = 0; mc <= nc; mc++) {
        x0 = ma > 0 ? (long long)dq[ma - 1][mb][mc][0] * ma % 1000000007 : 0;
        x1 = mb > 0 ? (long long)dq[ma][mb - 1][mc][1] * mb % 1000000007 : 0;
        x2 = mc > 0 ? (long long)dq[ma][mb][mc - 1][2] * mc % 1000000007 : 0;
        if (ma == 0 && mb == 0 && mc == 0) {
          dp[ma][mb][mc] = 1;
          dq[ma][mb][mc][0] = dq[ma][mb][mc][1] = dq[ma][mb][mc][2] = 1;
        } else {
          dp[ma][mb][mc] = ((long long)x0 + x1 + x2) % 1000000007;
          dq[ma][mb][mc][0] = (x1 + x2) % 1000000007;
          dq[ma][mb][mc][1] = (x0 + x2) % 1000000007;
          dq[ma][mb][mc][2] = (x0 + x1) % 1000000007;
        }
      }
}
void solve1(int *aa, int t, int n, int da[][50 + 1]) {
  int i, s, m, a;
  for (s = 0; s <= t; s++)
    for (m = 0; m <= n; m++) da[0][0] = 0;
  da[0][0] = 1;
  for (i = 0; i < n; i++) {
    a = aa[i];
    for (s = t; s >= a; s--)
      for (m = 1; m <= n; m++)
        da[s][m] = (da[s][m] + da[s - a][m - 1]) % 1000000007;
  }
}
void solve2(int *aa, int *bb, int t, int na, int nb,
            int dab[][50 + 1][50 + 1]) {
  static int da[2500 + 1][50 + 1];
  int i, b, s, ma, mb;
  solve1(aa, t, na, da);
  for (s = 0; s <= t; s++)
    for (ma = 0; ma <= na; ma++) {
      dab[s][ma][0] = da[s][ma];
      for (mb = 1; mb <= nb; mb++) dab[s][ma][mb] = 0;
    }
  for (i = 0; i < nb; i++) {
    b = bb[i];
    for (s = t; s >= b; s--)
      for (ma = 0; ma <= na; ma++)
        for (mb = 1; mb <= nb; mb++)
          dab[s][ma][mb] =
              (dab[s][ma][mb] + dab[s - b][ma][mb - 1]) % 1000000007;
  }
}
int main() {
  static int aa[50], bb[50], cc[50], dab[2500 + 1][50 + 1][50 + 1],
      dc[2500 + 1][50 + 1];
  int n, na, nb, nc, t, tab, tc, ma, mb, mc, xab, xc, ans;
  scanf("%d%d", &n, &t);
  na = nb = nc = 0;
  while (n--) {
    int a, g;
    scanf("%d%d", &a, &g);
    if (g == 1)
      aa[na++] = a;
    else if (g == 2)
      bb[nb++] = a;
    else
      cc[nc++] = a;
  }
  init(na, nb, nc);
  solve1(cc, t, nc, dc);
  solve2(aa, bb, t, na, nb, dab);
  ans = 0;
  for (tab = 0; tab <= t; tab++) {
    tc = t - tab;
    for (ma = 0; ma <= na; ma++)
      for (mb = 0; mb <= nb; mb++)
        if ((xab = dab[tab][ma][mb]))
          for (mc = 0; mc <= nc; mc++)
            if ((xc = dc[tc][mc]))
              ans = (ans + (long long)xab * xc % 1000000007 * dp[ma][mb][mc]) %
                    1000000007;
  }
  printf("%d\n", ans);
  return 0;
}
