#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
const int N = 5000000;
int d, i, n, T, j, k, l, fu[5], m, p;
long long dp[55][55][55][4], ans;
struct str {
  int t, g;
} a[55];
int main() {
  dp[0][0][0][0] = 1;
  for (i = 0; i <= 50; i++)
    for (j = 0; j <= 50; j++)
      for (k = 0; k <= 50; k++)
        for (p = 0; p <= 3; p++) {
          if (p != 1 && i != 0) dp[i][j][k][1] += dp[i - 1][j][k][p] * i % M;
          if (p != 2 && j != 0) dp[i][j][k][2] += dp[i][j - 1][k][p] * j % M;
          if (p != 3 && k != 0) dp[i][j][k][3] += dp[i][j][k - 1][p] * k % M;
        }
  scanf("%d %d", &n, &T);
  for (i = 1; i <= n; i++) {
    scanf("%d %d", &a[i].t, &a[i].g);
    fu[a[i].g]++;
  }
  long long f[T + 1][fu[1] + 1][fu[2] + 1][fu[3] + 1];
  memset(fu, 0, sizeof(fu));
  memset(f, 0, sizeof(f));
  f[0][0][0][0] = 1;
  for (i = 1; i <= n; i++) {
    fu[a[i].g]++;
    for (j = T; j >= a[i].t; j--)
      for (k = fu[1]; k >= 0; k--)
        for (l = fu[2]; l >= 0; l--)
          for (m = fu[3]; m >= 0; m--) {
            if (a[i].g == 1)
              if (k != 0) f[j][k][l][m] += f[j - a[i].t][k - 1][l][m];
            if (a[i].g == 2)
              if (l != 0) f[j][k][l][m] += f[j - a[i].t][k][l - 1][m];
            if (a[i].g == 3)
              if (m != 0) f[j][k][l][m] += f[j - a[i].t][k][l][m - 1];
            f[j][k][l][m] %= M;
          }
  }
  for (k = 0; k <= fu[1]; k++)
    for (l = 0; l <= fu[2]; l++)
      for (m = 0; m <= fu[3]; m++)
        ans = (ans + (dp[k][l][m][1] + dp[k][l][m][2] + dp[k][l][m][3]) % M *
                         f[T][k][l][m]) %
              M;
  cout << ans % M << endl;
}
