#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n;
long long k;
long long s, e;
int h;
struct mat {
  int n, m;
  long long a[20][20];
  mat() {
    n = m = 0;
    memset(a, 0, sizeof(a));
  }
  void init() {
    n = m = 0;
    memset(a, 0, sizeof(a));
  }
  void pr() {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) cout << a[i][j] << ' ';
      cout << endl;
    }
  }
  friend mat operator*(const mat &a, const mat &b) {
    mat c;
    c.n = a.n;
    c.m = b.m;
    for (int i = 1; i <= a.n; i++)
      for (int j = 1; j <= b.m; j++)
        for (int k = 1; k <= a.m; k++)
          c.a[i][j] = (c.a[i][j] + a.a[i][k] * b.a[k][j] % mod) % mod;
    return c;
  }
} init, acc;
mat qkpow(mat a, long long b) {
  if (b == 0) {
    mat ret;
    ret.n = a.n;
    ret.m = a.m;
    for (int i = 1; i <= a.n; i++) ret.a[i][i] = 1;
    return ret;
  }
  if (b == 1) return a;
  mat t = qkpow(a, b / 2);
  t = t * t;
  if (b % 2 == 1) t = t * a;
  return t;
}
int main() {
  init.m = 1;
  init.a[1][1] = 1;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> s >> e >> h;
    init.n = h + 1;
    acc.init();
    acc.n = h + 1;
    acc.m = h + 1;
    for (int j = 1; j <= acc.n; j++)
      acc.a[j][j - 1] = acc.a[j][j] = acc.a[j][j + 1] = 1;
    acc = qkpow(acc, min(e, k) - s);
    init = acc * init;
  }
  cout << init.a[1][1];
  return 0;
}
