#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
int n, t, dp[51][2501], dp1[51][51][2501], ways[51][51][51][4], a[4][50],
    freq[4];
void add(int &a, int b) {
  a += b;
  if (a >= M) a -= M;
  if (a < 0) a += M;
}
int main() {
  scanf("%d%d", &n, &t);
  for (int i = 0, t, g; i < n; i++) {
    scanf("%d%d", &t, &g);
    a[g][freq[g]] = t;
    freq[g]++;
  }
  ways[0][0][0][0] = 1;
  for (int i = 0; i <= 50; i++)
    for (int j = 0; j <= 50; j++)
      for (int k = 0; k <= 50; k++)
        for (int last = 1; last < 4; last++) {
          if (i && last == 1) {
            int temp = ways[i - 1][j][k][0] - ways[i - 1][j][k][1];
            ways[i][j][k][last] = i * 1LL * temp % M;
          }
          if (j && last == 2) {
            int temp = ways[i][j - 1][k][0] - ways[i][j - 1][k][2];
            ways[i][j][k][last] = j * 1LL * temp % M;
          }
          if (k && last == 3) {
            int temp = ways[i][j][k - 1][0] - ways[i][j][k - 1][3];
            ways[i][j][k][last] = k * 1LL * temp % M;
          }
          add(ways[i][j][k][0], ways[i][j][k][last]);
        }
  dp[0][0] = 1;
  for (int i = 0; i < freq[1]; i++)
    for (int j = i; j >= 0; j--)
      for (int k = t; k - a[1][i] >= 0; k--)
        add(dp[j + 1][k], dp[j][k - a[1][i]]);
  dp1[0][0][0] = 1;
  for (int i = 0; i < freq[2]; i++)
    for (int j = i; j >= 0; j--)
      for (int k = t; k - a[2][i] >= 0; k--)
        add(dp1[j + 1][0][k], dp1[j][0][k - a[2][i]]);
  for (int i = 0; i < freq[3]; i++)
    for (int j = freq[2]; j >= 0; j--)
      for (int l = i; l >= 0; l--)
        for (int k = t; k - a[3][i] >= 0; k--)
          add(dp1[j][l + 1][k], dp1[j][l][k - a[3][i]]);
  int ans = 0;
  for (int i = 0; i <= freq[1]; i++)
    for (int j = 0; j <= freq[2]; j++)
      for (int k = 0; k <= freq[3]; k++)
        for (int rem = 0; rem <= t; rem++)
          if (dp[i][rem] && dp1[j][k][t - rem])
            add(ans, (dp[i][rem] * 1LL * dp1[j][k][t - rem] % M) *
                         ways[i][j][k][0] % M);
  printf("%d\n", ans);
}
