#include <bits/stdc++.h>
using namespace std;
template <typename IntType>
void read(IntType& val) {
  val = 0;
  int c;
  bool inv = false;
  while (!isdigit(c = getchar()))
    if (c == '-') inv = true;
  do {
    val = (val << 1) + (val << 3) + c - '0';
  } while (isdigit(c = getchar()));
  if (inv) val = -val;
}
template <>
void read<string>(string& str) {
  str.clear();
  int c;
  while (iscntrl(c = getchar()) || c == ' ' || c == '\t')
    ;
  do {
    str.push_back(c);
  } while (!(iscntrl(c = getchar()) || c == ' ' || c == '\t'));
}
const int MaxN = 50 + 10, MaxT = 2500 + 200;
const long long Mod = 1e9 + 7;
int n, ts;
long long t[MaxN], g[MaxN];
long long cntg[5], durg[5];
long long a[MaxN][MaxT], bc[MaxN][MaxN][MaxT];
long long pe[MaxN][MaxN][MaxN][4];
long long fact[10000];
int main(int argc, char* argv[]) {
  read(n);
  read(ts);
  fact[0] = 1;
  for (int i = (1); i <= (9999); ++i) fact[i] = fact[i - 1] * i % Mod;
  a[0][0] = bc[0][0][0] = 1;
  for (int i = (1); i <= (n); ++i) {
    read(t[i]);
    read(g[i]);
    switch (g[i]) {
      case 1:
        for (int j = (ts); j >= (0); --j)
          for (int k = (cntg[1]); k >= (0); --k) {
            a[k + 1][j + t[i]] = (a[k + 1][j + t[i]] + a[k][j]) % Mod;
          }
        break;
      case 2:
        for (int j = (ts); j >= (0); --j)
          for (int k = (cntg[2]); k >= (0); --k)
            for (int l = (cntg[3]); l >= (0); --l) {
              bc[k + 1][l][j + t[i]] += bc[k][l][j];
              bc[k + 1][l][j + t[i]] %= Mod;
            }
        break;
      case 3:
        for (int j = (ts); j >= (0); --j)
          for (int k = (cntg[2]); k >= (0); --k)
            for (int l = (cntg[3]); l >= (0); --l) {
              bc[k][l + 1][j + t[i]] += bc[k][l][j];
              bc[k][l + 1][j + t[i]] %= Mod;
              if (bc[k][l + 1][j + t[i]])
                ;
            }
        break;
    }
    cntg[g[i]]++;
    durg[g[i]] += t[i];
  }
  pe[0][0][0][0] = 1;
  for (int x = (0); x <= (cntg[1]); ++x)
    for (int y = (0); y <= (cntg[2]); ++y)
      for (int z = (0); z <= (cntg[3]); ++z)
        for (int tr = (0); tr <= (3); ++tr)
          if (pe[x][y][z][tr]) {
            if (tr != 1 && x + 1 <= cntg[1]) {
              pe[x + 1][y][z][1] += pe[x][y][z][tr];
              pe[x + 1][y][z][1] %= Mod;
            }
            if (tr != 2 && y + 1 <= cntg[2]) {
              pe[x][y + 1][z][2] += pe[x][y][z][tr];
              pe[x][y + 1][z][2] %= Mod;
            }
            if (tr != 3 && z + 1 <= cntg[3]) {
              pe[x][y][z + 1][3] += pe[x][y][z][tr];
              pe[x][y][z + 1][3] %= Mod;
            }
          };
  ;
  long long ans = 0;
  for (int x = (0); x <= (cntg[1]); ++x) {
    for (int dur = (0); dur <= (ts); ++dur) {
      if (a[x][dur])
        for (int y = (0); y <= (cntg[2]); ++y)
          for (int z = (0); z <= (cntg[3]); ++z) {
            if (bc[y][z][ts - dur] != 0)
              ;
            else
              continue;
            long long dt = a[x][dur] * bc[y][z][ts - dur] % Mod;
            dt = dt * fact[x] % Mod;
            dt = dt * fact[y] % Mod;
            dt = dt * fact[z] % Mod;
            ans += dt * pe[x][y][z][1] % Mod;
            ans += dt * pe[x][y][z][2] % Mod;
            ans += dt * pe[x][y][z][3] % Mod;
            ans %= Mod;
            if (dt != 0)
              ;
          }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
