#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int SZ = 15;
int dp[2][SZ * SZ + 5][SZ + 2][SZ + 2][SZ + 2];
int dps[SZ + 5][SZ + 5][SZ + 5][5];
int fact[SZ + 5], timer[SZ + 5], typ[SZ + 5];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, times;
  cin >> n >> times;
  for (int i = 1; i <= n; i++) cin >> timer[i] >> typ[i];
  dp[0][0][0][0][0] = 1;
  int first = 0;
  for (int i = 1; i <= n; i++) {
    first ^= 1;
    for (int t = 0; t <= times; t++)
      for (int k1 = 0; k1 <= n; k1++)
        for (int k2 = 0; k2 <= n; k2++)
          for (int k3 = 0; k3 <= n; k3++) {
            dp[first][t][k1][k2][k3] = dp[first ^ 1][t][k1][k2][k3];
            if (timer[i] <= t) {
              if (typ[i] == 1 && k1 > 0)
                dp[first][t][k1][k2][k3] =
                    (dp[first][t][k1][k2][k3] +
                     dp[first ^ 1][t - timer[i]][k1 - 1][k2][k3]) %
                    MOD;
              if (typ[i] == 2 && k2 > 0)
                dp[first][t][k1][k2][k3] =
                    (dp[first][t][k1][k2][k3] +
                     dp[first ^ 1][t - timer[i]][k1][k2 - 1][k3]) %
                    MOD;
              if (typ[i] == 3 && k3 > 0)
                dp[first][t][k1][k2][k3] =
                    (dp[first][t][k1][k2][k3] +
                     dp[first ^ 1][t - timer[i]][k1][k2][k3 - 1]) %
                    MOD;
            }
          }
  }
  dps[1][0][0][1] = 1, dps[0][1][0][2] = 1, dps[0][0][1][3] = 1;
  for (int k1 = 0; k1 <= n; k1++)
    for (int k2 = 0; k2 <= n; k2++)
      for (int k3 = 0; k3 <= n; k3++) {
        if (k1 + k2 + k3 <= 1) continue;
        if (k1 != 0)
          dps[k1][k2][k3][1] =
              (dps[k1 - 1][k2][k3][2] + dps[k1 - 1][k2][k3][3]) % MOD;
        if (k2 != 0)
          dps[k1][k2][k3][2] =
              (dps[k1][k2 - 1][k3][1] + dps[k1][k2 - 1][k3][3]) % MOD;
        if (k3 != 0)
          dps[k1][k2][k3][3] =
              (dps[k1][k2][k3 - 1][1] + dps[k1][k2][k3 - 1][2]) % MOD;
      }
  fact[0] = 1;
  for (int i = 1; i <= n; i++)
    fact[i] = (long long)fact[i - 1] * (long long)i % (long long)MOD;
  int answer = 0;
  for (int k1 = 0; k1 <= n; k1++)
    for (int k2 = 0; k2 <= n; k2++)
      for (int k3 = 0; k3 <= n; k3++) {
        int sum = ((dps[k1][k2][k3][1] + dps[k1][k2][k3][2]) % MOD +
                   dps[k1][k2][k3][3]) %
                  MOD;
        int pr = (long long)fact[k1] * (long long)fact[k2] % (long long)MOD *
                 (long long)fact[k3] % (long long)MOD;
        answer = ((long long)answer + (long long)dp[first][times][k1][k2][k3] *
                                          (long long)sum % (long long)MOD *
                                          (long long)pr) %
                 (long long)MOD;
      }
  cout << answer;
  return 0;
}
