#include <bits/stdc++.h>
using namespace std;
const int MAXN = 50 + 1;
const int MOD = 1e9 + 7;
int n, T;
vector<vector<int>> times(3);
vector<vector<int>> combines;
inline int encode(int x, int y, int z, int n1, int n2) {
  return x * (n1 + 1) * (n2 + 1) + y * (n2 + 1) + z;
}
void findCombines(vector<int> nums, int n1, int n2) {
  for (int g = 0; g < 3; ++g) {
    int current = encode(nums[0], nums[1], nums[2], n1, n2);
    if (combines[current][g] == -1) {
      combines[current][g] = 0;
      if (nums[g] != 0) {
        --nums[g];
        int prev = encode(nums[0], nums[1], nums[2], n1, n2);
        findCombines(nums, n1, n2);
        ++nums[g];
        if (prev == 0) {
          combines[current][g] = 1;
        } else {
          for (int pg = 0; pg < 3; ++pg) {
            if (g != pg) {
              (combines[current][g] += combines[prev][pg]) %= MOD;
            }
          }
        }
      }
    }
  }
}
vector<vector<int>> accTimes;
void getAccTimes(const vector<int>& times, int g, vector<int> ns) {
  vector<int> nums(3);
  for (auto t : times) {
    for (nums[0] = ns[0]; nums[0] >= 0; --nums[0]) {
      for (nums[1] = ns[1]; nums[1] >= 0; --nums[1]) {
        for (nums[2] = ns[2]; nums[2] >= 0; --nums[2]) {
          if (nums[g] > 0) {
            int current = encode(nums[0], nums[1], nums[2], ns[1], ns[2]);
            for (int i = T; i - t >= 0; --i) {
              --nums[g];
              int prev = encode(nums[0], nums[1], nums[2], ns[1], ns[2]);
              (accTimes[current][i] += accTimes[prev][i - t]) %= MOD;
              ++nums[g];
            }
          }
        }
      }
    }
  }
}
long long facts[MAXN];
void initFacts() {
  facts[0] = 1;
  for (int i = 1; i < MAXN; ++i) {
    (facts[i] = facts[i - 1] * i) %= MOD;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> T;
  for (int i = 0, t, g; i < n; ++i) {
    cin >> t >> g;
    times[g - 1].push_back(t);
  }
  int n0 = static_cast<int>(times[0].size());
  int n1 = static_cast<int>(times[1].size());
  int n2 = static_cast<int>(times[2].size());
  int m = (n0 + 1) * (n1 + 1) * (n2 + 1);
  combines = vector<vector<int>>(m, vector<int>(3, -1));
  findCombines({n0, n1, n2}, n1, n2);
  accTimes = vector<vector<int>>(m, vector<int>(T + 1));
  accTimes[0][0] = 1;
  for (int g = 0; g < 3; ++g) {
    getAccTimes(times[g], g, {n0, n1, n2});
  }
  initFacts();
  int total = 0;
  for (int i = 0; i <= n0; ++i) {
    for (int j = 0; j <= n1; ++j) {
      for (int k = 0; k <= n2; ++k) {
        int current = encode(i, j, k, n1, n2);
        int base = accTimes[current][T];
        if (base) {
          int combineNum = 0;
          for (int g = 0; g < 3; ++g) {
            (combineNum += combines[current][g]) %= MOD;
          }
          if (combineNum) {
            long long factNum = 0;
            factNum = facts[i] * facts[j] % MOD * facts[k] % MOD;
            (total += base * factNum % MOD * combineNum % MOD) %= MOD;
          }
        }
      }
    }
  }
  cout << total << endl;
  return 0;
}
