#include <bits/stdc++.h>
using namespace std;
pair<int, int> vec[16];
int vf[4], v[16], cnt = 0;
void bkt(int a, int b, int c) {
  if (a == vf[1] && b == vf[2] && c == vf[3]) {
    cnt++;
    return;
  }
  if (v[a + b + c] == 1) {
    if (b == vf[2] && c == vf[3])
      return;
    else if (b == vf[2]) {
      v[a + b + c + 1] = 3;
      bkt(a, b, c + 1);
    } else {
      v[a + b + c + 1] = 2;
      bkt(a, b + 1, c);
      if (c != vf[3]) {
        v[a + b + c + 1] = 3;
        bkt(a, b, c + 1);
      }
    }
  }
  if (v[a + b + c] == 2) {
    if (a == vf[1] && c == vf[3])
      return;
    else if (a == vf[1]) {
      v[a + b + c + 1] = 3;
      bkt(a, b, c + 1);
    } else {
      v[a + b + c + 1] = 1;
      bkt(a + 1, b, c);
      if (c != vf[3]) {
        v[a + b + c + 1] = 3;
        bkt(a, b, c + 1);
      }
    }
  }
  if (v[a + b + c] == 3) {
    if (b == vf[2] && a == vf[1])
      return;
    else if (b == vf[2]) {
      v[a + b + c + 1] = 1;
      bkt(a + 1, b, c);
    } else {
      v[a + b + c + 1] = 2;
      bkt(a, b + 1, c);
      if (a != vf[1]) {
        v[a + b + c + 1] = 1;
        bkt(a + 1, b, c);
      }
    }
  }
}
long long fact[16];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, t, i, timp, j;
  long long cnt1 = 0;
  cin >> n >> t;
  for (i = 1; i <= n; i++) cin >> vec[i].first >> vec[i].second;
  fact[0] = 1;
  for (i = 1; i <= 15; i++) fact[i] = 1LL * fact[i - 1] * i;
  for (i = 1; i < (1 << n); i++) {
    vf[1] = vf[2] = vf[3] = 0;
    timp = 0;
    for (j = 0; j < n; j++)
      if (i & (1 << j)) {
        timp += vec[j + 1].first;
        vf[vec[j + 1].second]++;
      }
    if (2 * max(vf[1], max(vf[2], vf[3])) <=
            vf[1] + vf[2] + vf[3] + 2 * ((vf[1] + vf[2] + vf[3]) % 2) &&
        timp == t) {
      cnt = 0;
      if (vf[1]) {
        v[1] = 1;
        bkt(1, 0, 0);
      }
      if (vf[2]) {
        v[1] = 2;
        bkt(0, 1, 0);
      }
      if (vf[3]) {
        v[1] = 3;
        bkt(0, 0, 1);
      }
      cnt1 = (cnt1 + 1LL * cnt * fact[vf[1]] * fact[vf[2]] * fact[vf[3]]) %
             (1000000007);
    }
  }
  cout << cnt1;
  return 0;
}
