#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int K = 15;
vector<vector<long long> > mul(vector<vector<long long> > A,
                               vector<vector<long long> > B) {
  vector<vector<long long> > C(K + 1, vector<long long>(K + 1));
  for (int i = 0; i <= K; i++)
    for (int j = 0; j <= K; j++)
      for (int k = 0; k <= K; k++)
        C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
  return C;
}
vector<vector<long long> > pow(vector<vector<long long> > A, long long p) {
  if (p == 1) return A;
  if (p % 2) return mul(A, pow(A, p - 1));
  vector<vector<long long> > X = pow(A, p / 2);
  return mul(X, X);
}
void print(vector<vector<long long> > a) {
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      cout << a[i][j] << " ";
    }
    cout << "\n";
  }
  cout << "***********************************************************\n";
}
int main() {
  long long n, k;
  cin >> n >> k;
  long long a, b, c;
  vector<vector<long long> > answer(K + 1, vector<long long>(K + 1));
  answer[15][0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> a >> b >> c;
    if (k == a) {
      return cout << answer[15][0], 0;
    }
    if (k <= b) {
      b = k;
    }
    vector<vector<long long> > m(K + 1, vector<long long>(K + 1));
    m[15][15] = 1;
    if (c > 0) m[15][14] = 1;
    for (int j = 1; j <= c; j++) {
      m[15 - j][15 - j] = 1;
      if (j != c) m[15 - j][15 - j - 1] = 1;
      m[15 - j][15 - j + 1] = 1;
    }
    m = pow(m, b - a);
    answer = mul(m, answer);
    if (k == b) return cout << answer[15][0], 0;
  }
  return 0;
}
