#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, T, cnt[4], sum[4], fac[55], f[55][2505], gh[55][55][2505],
    p[55][55][55][4], s[55][55][55];
void add(int &a, int b) { (a += b) >= mod && (a -= mod); }
int main() {
  scanf("%d%d", &n, &T);
  f[0][0] = gh[0][0][0] = fac[0] = 1;
  for (int o = 1, t, id; o <= n; o++) {
    scanf("%d%d", &t, &id);
    if (id == 1) {
      for (int i = (cnt[1]), LIM = (0); i >= LIM; i--)
        for (int j = (sum[1]), LIM = (0); j >= LIM; j--)
          if (f[i][j]) add(f[i + 1][j + t], f[i][j]);
    } else {
      for (int i = (cnt[2]), LIM = (0); i >= LIM; i--)
        for (int j = (cnt[3]), LIM = (0); j >= LIM; j--)
          for (int k = (sum[2] + sum[3]), LIM = (0); k >= LIM; k--)
            if (gh[i][j][k])
              add(gh[i + (id == 2)][j + (id == 3)][k + t], gh[i][j][k]);
    }
    fac[o] = 1ll * fac[o - 1] * o % mod;
    cnt[id]++, sum[id] += t;
  }
  p[1][0][0][1] = p[0][1][0][2] = p[0][0][1][3] = 1;
  for (int i = (0), LIM = (cnt[1]); i <= LIM; i++)
    for (int j = (0), LIM = (cnt[2]); j <= LIM; j++)
      for (int k = (0), LIM = (cnt[3]); k <= LIM; k++) {
        add(p[i + 1][j][k][1], (p[i][j][k][2] + p[i][j][k][3]) % mod);
        add(p[i][j + 1][k][2], (p[i][j][k][1] + p[i][j][k][3]) % mod);
        add(p[i][j][k + 1][3], (p[i][j][k][1] + p[i][j][k][2]) % mod);
        s[i][j][k] = (1ll * p[i][j][k][1] + p[i][j][k][2] + p[i][j][k][3]) *
                     fac[i] % mod * fac[j] % mod * fac[k] % mod;
      }
  int ans = 0;
  for (int i = (0), LIM = (cnt[1]); i <= LIM; i++)
    for (int t = (0), LIM = (sum[1]); t <= LIM; t++)
      if (f[i][t])
        for (int j = (0), LIM = (cnt[2]); j <= LIM; j++)
          for (int k = (0), LIM = (cnt[3]); k <= LIM; k++)
            add(ans, 1ll * f[i][t] * gh[j][k][T - t] % mod * s[i][j][k] % mod);
  printf("%d\n", ans);
}
