#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
long long dp[1 << 16][4];
const int mod = 1e9 + 7;
long long ans;
int n, m;
int t[N], v[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1); i <= (n); i++)
    scanf("%d%d", &t[i], &v[i]), dp[1 << (i - 1)][v[i]] = 1;
  for (int state = (0); state <= ((1 << n) - 1); state++)
    for (int last = (1); last <= (3); last++)
      for (int now = (1); now <= (n); now++) {
        if (state & 1 << (now - 1)) continue;
        if (last == v[now]) continue;
        int k = state | (1 << now - 1);
        dp[k][v[now]] = (dp[k][v[now]] + dp[state][last]) % mod;
      }
  for (int state = (1); state <= ((1 << n) - 1); state++) {
    int sum = 0;
    for (int j = (1); j <= (n); j++) {
      if (state & (1 << (j - 1))) sum += t[j];
    }
    if (sum == m) {
      for (int k = (1); k <= (3); k++) ans = (ans + dp[state][k]) % mod;
    }
  }
  cout << ans;
  return 0;
}
