#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
const long long mod = 1000000007;
pair<long long, long long> v[MAXN];
long long n, t;
long long memo[5510][2510];
long long comp[5510][2510];
long long q1 = 0, q2 = 0, q3 = 0;
long long f[55];
long long r[51][51][51];
long long p[52][52][52][5];
long long pd(long long x, long long y, long long z, long long last) {
  if (x == 0 && y == 0 && z == 0) return 1;
  if (x < 0 || y < 0 || z < 0) return 0;
  if (p[x][y][z][last] != -1) return p[x][y][z][last];
  if (last == 0)
    p[x][y][z][last] =
        pd(x, y, z - 1, 3) + pd(x, y - 1, z, 2) + pd(x - 1, y, z, 1);
  if (last == 1) p[x][y][z][last] = pd(x, y - 1, z, 2) + pd(x, y, z - 1, 3);
  if (last == 2) p[x][y][z][last] = pd(x - 1, y, z, 1) + pd(x, y, z - 1, 3);
  if (last == 3) p[x][y][z][last] = pd(x - 1, y, z, 1) + pd(x, y - 1, z, 2);
  p[x][y][z][last] %= mod;
  return p[x][y][z][last];
}
signed main() {
  f[0] = 1;
  memset(p, -1, sizeof p);
  cin >> n >> t;
  for (long long i = 1; i <= n; i++) {
    long long x, y;
    cin >> x >> y;
    v[i] = {y, x};
    if (y == 1)
      q1++;
    else if (y == 2)
      q2++;
    else
      q3++;
  }
  long long cnt = 0;
  for (long long j1 = 0; j1 <= q1; j1++) {
    for (long long j2 = 0; j2 <= q2; j2++) {
      for (long long j3 = 0; j3 <= q3; j3++) {
        cnt++;
        r[j1][j2][j3] = cnt;
      }
    }
  }
  memo[r[0][0][0]][0] = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long j1 = 0; j1 <= q1; j1++) {
      for (long long j2 = 0; j2 <= q2; j2++) {
        for (long long j3 = 0; j3 <= q3; j3++) {
          for (long long k = 0; k <= t; k++) {
            comp[r[j1][j2][j3]][k] = memo[r[j1][j2][j3]][k];
            if (k - v[i].second < 0) continue;
            if (v[i].first == 1 && j1 > 0)
              memo[r[j1][j2][j3]][k] +=
                  comp[r[j1 - 1][j2][j3]][k - v[i].second];
            else if (v[i].first == 2 && j2 > 0)
              memo[r[j1][j2][j3]][k] +=
                  comp[r[j1][j2 - 1][j3]][k - v[i].second];
            else if (v[i].first == 3 && j3 > 0)
              memo[r[j1][j2][j3]][k] +=
                  comp[r[j1][j2][j3 - 1]][k - v[i].second];
            if (memo[r[j1][j2][j3]][k] > 1000000000)
              memo[r[j1][j2][j3]][k] %= mod;
          }
        }
      }
    }
  }
  for (long long i = 1; i <= 50; i++) f[i] = (f[i - 1] * i) % mod;
  long long resp = 0;
  for (long long j1 = 0; j1 <= q1; j1++) {
    for (long long j2 = 0; j2 <= q2; j2++) {
      for (long long j3 = 0; j3 <= q3; j3++) {
        long long h = ((((f[j1] % mod) * f[j2]) % mod) * f[j3]) % mod;
        resp += (memo[r[j1][j2][j3]][t] * pd(j1, j2, j3, 0)) % mod * h;
        resp %= mod;
      }
    }
  }
  cout << resp << endl;
}
