#include <bits/stdc++.h>
const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const long long MXLL = 9223372036854775807;
const int Sz = 1110111;
using namespace std;
inline void Read_rap() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int n;
long long k;
struct matrix {
  long long a[16][16];
  int n;
  matrix() {
    n = 16;
    memset(a, 0, sizeof a);
  }
  inline matrix operator*(matrix b) {
    matrix c;
    for (int i = 0; i < n; ++i)
      for (int k = 0; k < n; ++k)
        for (int j = 0; j < n; ++j)
          c.a[i][j] += (a[i][k] * b.a[k][j]) % Mod, c.a[i][j] %= Mod;
    return c;
  }
  inline void show() {
    for (int i = 0; i < n; i++, cout << endl)
      for (int j = 0; j < n; j++) cout << a[i][j] << ' ';
  }
};
inline void binpow(matrix &a, matrix b, long long n) {
  while (n) {
    if (n & 1) a = a * b;
    b = b * b;
    n >>= 1;
  }
}
inline matrix make_matrix(int n) {
  matrix b;
  for (int i = 0; i <= n; i++) {
    if (i) b.a[i][i - 1] = 1;
    b.a[i][i] = 1;
    if (i + 1 <= n) b.a[i][i + 1] = 1;
  }
  return b;
}
long long s[101][101];
int main() {
  Read_rap();
  cin >> n >> k;
  matrix dp, b;
  dp.a[0][0] = 1;
  s[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    long long l, r, c;
    cin >> l >> r >> c;
    b = make_matrix(c);
    binpow(dp, b, min(k, r) - l);
  }
  cout << dp.a[0][0];
  return 0;
}
