#include <bits/stdc++.h>
using namespace std;
using namespace std;
const long long mod = 1e9 + 7;
long long A[100], B[100];
int C[100];
int n;
long long t;
vector<vector<long long> > mult(const vector<vector<long long> >& A,
                                const vector<vector<long long> >& B) {
  int c = A.size();
  vector<vector<long long> > ret(c, vector<long long>(c, 0L));
  for (int i = 0; i < int(c); i++)
    for (int j = 0; j < int(c); j++)
      for (int k = 0; k < int(c); k++)
        ret[i][j] = (ret[i][j] + A[i][k] * B[k][j]) % mod;
  return ret;
}
vector<vector<long long> > f(long long pow, int c) {
  if (c == 1) {
    return {{1L}};
  }
  vector<vector<long long> > B(c, vector<long long>(c, 0L));
  B[0][0] = B[0][1] = 1L;
  for (int i = 1; i < int(c - 1); i++) B[i][i - 1] = B[i][i] = B[i][i + 1] = 1L;
  B[c - 1][c - 2] = B[c - 1][c - 1] = 1L;
  if (pow == 1) return B;
  vector<vector<long long> > A = f(pow >> 1L, c);
  vector<vector<long long> > ret = mult(A, A);
  if (pow & 1L) ret = mult(ret, B);
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> t;
  for (int i = 0; i < int(n); i++) cin >> A[i] >> B[i] >> C[i];
  vector<long long> ans(16, 0L);
  ans[0] = 1L;
  for (int i = 0; i < int(n); i++) {
    if (A[i] == t) break;
    vector<vector<long long> > M = f(min(t, B[i]) - A[i], C[i] + 1);
    if (i > 0)
      for (int j = min(C[i], C[i - 1]) + 1; j < int(16); j++) ans[j] = 0;
    vector<long long> tmp(16, 0L);
    for (int k = 0; k < int(C[i] + 1); k++)
      for (int j = 0; j < int(C[i] + 1); j++)
        tmp[k] = (tmp[k] + M[k][j] * ans[j]) % mod;
    ans = tmp;
  }
  cout << ans[0] << endl;
  return 0;
}
