#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long maxn = 3e5 + 5;
const long long SQ = 317;
long long dp[15][15][15][15];
long long zez[16];
long long fact[16];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  fact[0] = 1;
  for (long long i = 1; i < 16; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
  }
  long long kek = 1;
  for (long long i = 0; i < 15; i++) {
    zez[i] = kek;
    kek *= 3;
  }
  zez[15] = kek;
  for (long long jj = 0; jj <= 15; jj++) {
    for (long long i = 0; i < zez[jj]; i++) {
      long long zz = i;
      long long cnt[3] = {};
      long long last = -1;
      bool fl = 1;
      for (long long j = 0; j < jj; j++) {
        if (zz % 3 == last) fl = 0;
        cnt[zz % 3]++;
        last = zz % 3;
        zz /= 3;
      }
      dp[cnt[0]][cnt[1]][cnt[2]][cnt[0] + cnt[1] + cnt[2]] += fl;
      (dp[cnt[0]][cnt[1]][cnt[2]][cnt[0] + cnt[1] + cnt[2]]) %= mod;
    }
  }
  long long n, x;
  cin >> n >> x;
  long long t[n], g[n];
  for (long long i = 0; i < n; i++) {
    cin >> t[i] >> g[i];
  }
  long long ans = 0;
  for (long long msk = 0; msk < (1 << n); msk++) {
    vector<long long> a;
    long long xx = 0;
    long long cnt[3] = {};
    for (long long j = 0; j < n; j++) {
      if ((1 << j) & msk) {
        xx += t[j];
        a.push_back(g[j]);
        cnt[g[j] - 1]++;
      }
    }
    if (xx != x) continue;
    ans +=
        (dp[cnt[0]][cnt[1]][cnt[2]][cnt[0] + cnt[1] + cnt[2]] * fact[cnt[0]]) %
        mod * (fact[cnt[1]] * fact[cnt[2]]) % mod;
    ans %= mod;
  }
  cout << ans;
  return 0;
}
