#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int n, tt;
vector<pair<int, int>> sg;
long long scc[3][15][15][15];
long long srec(int p, int a, int b, int c) {
  if (a + b + c == 0) return 1;
  auto& v = scc[p - 1][a][b][c];
  if (v != -1) return v;
  long long cc = 0;
  if (a > 0 && p != 1) cc += a * srec(1, a - 1, b, c);
  if (b > 0 && p != 2) cc += b * srec(2, a, b - 1, c);
  if (c > 0 && p != 3) cc += c * srec(3, a, b, c - 1);
  return v = (cc % mod);
}
long long rec(int r, vector<pair<int, int>>& tsg) {
  if (r == n) {
    int a = 0, b = 0, c = 0, t = 0;
    for (int i = 0; i < tsg.size(); ++i) {
      if (tsg[i].second == 1) a++;
      if (tsg[i].second == 2) b++;
      if (tsg[i].second == 3) c++;
      t += tsg[i].first;
    }
    if (t != tt) return 0;
    long long cc = 0;
    if (a > 0) cc += a * srec(1, a - 1, b, c);
    if (b > 0) cc += b * srec(2, a, b - 1, c);
    if (c > 0) cc += c * srec(3, a, b, c - 1);
    return cc % mod;
  }
  long long cc = 0;
  tsg.push_back(sg[r]);
  cc += rec(r + 1, tsg);
  tsg.pop_back();
  cc += rec(r + 1, tsg);
  return cc % mod;
}
int main() {
  cin >> n >> tt;
  for (int i = 0; i < n; ++i) {
    int t, g;
    cin >> t >> g;
    sg.push_back(make_pair(t, g));
  }
  for (int i = 0; i < 3; ++i)
    for (int a = 0; a < 15; ++a)
      for (int b = 0; b < 15; ++b)
        for (int c = 0; c < 15; ++c) scc[i][a][b][c] = -1;
  vector<pair<int, int>> tsg;
  long long cc = rec(0, tsg);
  cout << cc << endl;
}
