#include <bits/stdc++.h>
long long dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
long long dy[8] = {1, 0, -1, 0, -1, 1, 1, -1};
using namespace std;
class pa3 {
 public:
  long long x;
  long long y, z;
  pa3(long long x = 0, long long y = 0, long long z = 0) : x(x), y(y), z(z) {}
  bool operator<(const pa3 &p) const {
    if (x != p.x) return x < p.x;
    if (y != p.y) return y < p.y;
    return z < p.z;
  }
  bool operator>(const pa3 &p) const {
    if (x != p.x) return x > p.x;
    if (y != p.y) return y > p.y;
    return z > p.z;
  }
  bool operator==(const pa3 &p) const {
    return x == p.x && y == p.y && z == p.z;
  }
  bool operator!=(const pa3 &p) const {
    return !(x == p.x && y == p.y && z == p.z);
  }
};
class pa4 {
 public:
  long long x;
  long long y, z, w;
  pa4(long long x = 0, long long y = 0, long long z = 0, long long w = 0)
      : x(x), y(y), z(z), w(w) {}
  bool operator<(const pa4 &p) const {
    if (x != p.x) return x < p.x;
    if (y != p.y) return y < p.y;
    if (z != p.z) return z < p.z;
    return w < p.w;
  }
  bool operator>(const pa4 &p) const {
    if (x != p.x) return x > p.x;
    if (y != p.y) return y > p.y;
    if (z != p.z) return z > p.z;
    return w > p.w;
  }
  bool operator==(const pa4 &p) const {
    return x == p.x && y == p.y && z == p.z && w == p.w;
  }
};
class pa2 {
 public:
  long long x, y;
  pa2(long long x = 0, long long y = 0) : x(x), y(y) {}
  pa2 operator+(pa2 p) { return pa2(x + p.x, y + p.y); }
  pa2 operator-(pa2 p) { return pa2(x - p.x, y - p.y); }
  bool operator<(const pa2 &p) const { return y != p.y ? y < p.y : x < p.x; }
  bool operator>(const pa2 &p) const { return x != p.x ? x < p.x : y < p.y; }
  bool operator==(const pa2 &p) const {
    return abs(x - p.x) == 0 && abs(y - p.y) == 0;
  }
  bool operator!=(const pa2 &p) const {
    return !(abs(x - p.x) == 0 && abs(y - p.y) == 0);
  }
};
string itos(long long i) {
  ostringstream s;
  s << i;
  return s.str();
}
long long gcd(long long v, long long b) {
  if (v > b) return gcd(b, v);
  if (v == b) return b;
  if (b % v == 0) return v;
  return gcd(v, b % v);
}
long long mod;
long long extgcd(long long a, long long b, long long &x, long long &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long d = extgcd(b, a % b, y, x);
  y -= a / b * x;
  return d;
}
pair<long long, long long> operator+(const pair<long long, long long> &l,
                                     const pair<long long, long long> &r) {
  return {l.first + r.first, l.second + r.second};
}
pair<long long, long long> operator-(const pair<long long, long long> &l,
                                     const pair<long long, long long> &r) {
  return {l.first - r.first, l.second - r.second};
}
long long pr[200010];
long long inv[200010];
long long beki(long long wa, long long rr, long long warukazu) {
  if (rr == 0) return 1 % warukazu;
  if (rr == 1) return wa % warukazu;
  wa %= warukazu;
  if (rr % 2 == 1)
    return ((long long)beki(wa, rr - 1, warukazu) * (long long)wa) % warukazu;
  long long zx = beki(wa, rr / 2, warukazu);
  return (zx * zx) % warukazu;
}
long long comb(long long nn, long long rr) {
  if (rr < 0 || rr > nn || nn < 0) return 0;
  long long r = pr[nn] * inv[rr];
  r %= mod;
  r *= inv[nn - rr];
  r %= mod;
  return r;
}
void gya(long long ert) {
  pr[0] = 1;
  for (long long i = 1; i <= ert; i++) {
    pr[i] = (pr[i - 1] * i) % mod;
  }
  inv[ert] = beki(pr[ert], mod - 2, mod);
  for (long long i = ert - 1; i >= 0; i--) {
    inv[i] = inv[i + 1] * (i + 1) % mod;
  }
}
long long dp[2][51][51][2501] = {};
long long dp2[51][51][2501] = {};
long long fp[51][51][51][3] = {};
long long solve(long long i, long long j, long long k) {
  return (fp[i][j][k][0] + fp[i][j][k][1] + fp[i][j][k][2]) % 1000000007;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, T;
  cin >> n >> T;
  vector<long long> ve[3];
  for (long long i = 0; i < n; i++) {
    long long y, yy;
    cin >> y >> yy;
    yy--;
    ve[yy].push_back(y);
  }
  long long a = ve[0].size();
  long long b = ve[1].size();
  long long c = ve[2].size();
  fp[1][0][0][0] = 1;
  fp[0][1][0][1] = 1;
  fp[0][0][1][2] = 1;
  for (long long i = 0; i <= a; i++)
    for (long long j = 0; j <= b; j++)
      for (long long k = 0; k <= c; k++)
        for (long long h = 0; h < 3; h++) {
          if (i + j + k <= 1) continue;
          if (h == 0 && i > 0) {
            fp[i][j][k][h] =
                (fp[i - 1][j][k][1] + fp[i - 1][j][k][2]) * i % 1000000007;
          }
          if (h == 1 && j > 0) {
            fp[i][j][k][h] =
                (fp[i][j - 1][k][0] + fp[i][j - 1][k][2]) * j % 1000000007;
          }
          if (h == 2 && k > 0) {
            fp[i][j][k][h] =
                (fp[i][j][k - 1][0] + fp[i][j][k - 1][1]) * k % 1000000007;
          }
        }
  dp[0][0][0][0] = 1;
  for (long long i = 0; i < a; i++) {
    for (long long j = 0; j <= i; j++)
      for (long long h = j; h <= j * 50; h++)
        if (dp[i % 2][j][0][h]) {
          dp[1 - i % 2][j][0][h] += dp[i % 2][j][0][h];
          if (dp[1 - i % 2][j][0][h] >= 1000000007)
            dp[1 - i % 2][j][0][h] -= 1000000007;
          dp[1 - i % 2][j + 1][0][h + ve[0][i]] += dp[i % 2][j][0][h];
          if (dp[1 - i % 2][j + 1][0][h + ve[0][i]] >= 1000000007)
            dp[1 - i % 2][j + 1][0][h + ve[0][i]] -= 1000000007;
          dp[i % 2][j][0][h] = 0;
        }
  }
  for (long long i = 0; i < b; i++) {
    for (long long j = 0; j <= 50; j++)
      for (long long k = 0; k <= 50; k++)
        for (long long h = 0; h <= 2500; h++) dp[(a + i + 1) % 2][j][k][h] = 0;
    for (long long j = 0; j <= a; j++)
      for (long long k = 0; k <= i; k++)
        for (long long h = (k + j); h <= (k + j) * 50; h++)
          if (dp[(a + i) % 2][j][k][h]) {
            dp[(a + i + 1) % 2][j][k][h] += dp[(a + i) % 2][j][k][h];
            if (dp[(a + i + 1) % 2][j][k][h] >= 1000000007)
              dp[(a + i + 1) % 2][j][k][h] -= 1000000007;
            dp[(a + i + 1) % 2][j][k + 1][h + ve[1][i]] +=
                dp[(a + i) % 2][j][k][h];
            if (dp[(a + i + 1) % 2][j][k + 1][h + ve[1][i]] >= 1000000007)
              dp[(a + i + 1) % 2][j][k + 1][h + ve[1][i]] -= 1000000007;
            dp[(a + i) % 2][j][k][h] = 0;
          }
  }
  dp2[0][0][0] = 1;
  for (long long i = 0; i < c; i++) {
    for (long long j = 0; j <= i; j++)
      for (long long h = j; h <= 50 * j; h++)
        if (dp2[i][j][h]) {
          dp2[i + 1][j][h] += dp2[i][j][h];
          if (dp2[i + 1][j][h] >= 1000000007) dp2[i + 1][j][h] -= 1000000007;
          dp2[i + 1][j + 1][h + ve[2][i]] += dp2[i][j][h];
          if (dp2[i + 1][j + 1][h + ve[2][i]] >= 1000000007)
            dp2[i + 1][j + 1][h + ve[2][i]] -= 1000000007;
        }
  }
  long long ans = 0;
  for (long long i = 0; i <= a; i++)
    for (long long j = 0; j <= b; j++)
      for (long long k = 0; k <= c; k++)
        for (long long h = k; h <= k * 50; h++) {
          long long w = T - h;
          if (i + j > w) continue;
          if ((i + j) * 50 < w) continue;
          long long memo = dp[(a + b) % 2][i][j][w];
          memo *= dp2[c][k][h];
          memo %= 1000000007;
          memo *= solve(i, j, k);
          memo %= 1000000007;
          ans += memo;
          if (ans >= 1000000007) ans -= 1000000007;
        }
  cout << ans << endl;
  return 0;
}
