#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64777216")
using namespace std;
const int inf = (int)1e9 + 5;
const long long INF = (long long)1e18 + 5;
const long long mod = 1e9 + 7;
const long long maxt = 17;
long long dp[maxt][maxt][maxt][3];
long long add(long long x, long long y) { return (x + y) % mod; }
long long mult(long long x, long long y) { return (x * y) % mod; }
void add_to(long long &x, long long y) {
  x += y;
  if (x >= mod) x -= mod;
}
void solve() {
  long long n, T;
  cin >> n >> T;
  vector<long long> a(n), G(n);
  for (long long i = 0; i < n; i++) cin >> a[i] >> G[i];
  long long ans = 0;
  for (long long mask = 0; mask < (1 << n); mask++) {
    long long cur_t = 0;
    vector<long long> cnt(3, 0);
    for (long long i = 0; i < n; i++)
      if (mask & (1 << i)) {
        cur_t += a[i];
        cnt[G[i] - 1]++;
      }
    if (cur_t != T) continue;
    long long total_cnt = cnt[0] + cnt[1] + cnt[2];
    memset(dp, 0, sizeof(dp));
    dp[1][0][0][0] = cnt[0];
    dp[0][1][0][1] = cnt[1];
    dp[0][0][1][2] = cnt[2];
    for (long long c = 1; c <= total_cnt; c++) {
      for (long long c1 = 0; c1 <= cnt[0]; c1++)
        for (long long c2 = 0; c2 <= cnt[1] && c1 + c2 <= c; c2++) {
          long long c3 = c - (c1 + c2);
          if (c3 > cnt[2]) {
            c2 = c - c1 - cnt[2] - 1;
            continue;
          }
          if (c == total_cnt) {
            for (long long last = 0; last < 3; last++)
              add_to(ans, dp[c1][c2][c3][last]);
          } else {
            add_to(dp[c1][c2 + 1][c3][1], mult(dp[c1][c2][c3][0], cnt[1] - c2));
            add_to(dp[c1][c2][c3 + 1][2], mult(dp[c1][c2][c3][0], cnt[2] - c3));
            add_to(dp[c1 + 1][c2][c3][0], mult(dp[c1][c2][c3][1], cnt[0] - c1));
            add_to(dp[c1][c2][c3 + 1][2], mult(dp[c1][c2][c3][1], cnt[2] - c3));
            add_to(dp[c1][c2 + 1][c3][1], mult(dp[c1][c2][c3][2], cnt[1] - c2));
            add_to(dp[c1 + 1][c2][c3][0], mult(dp[c1][c2][c3][2], cnt[0] - c1));
          }
        }
    }
  }
  cout << ans << endl;
}
int main() {
  string filename = "acm";
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(15);
  solve();
  (void)0;
  return 0;
}
