#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
struct Node {
  long long l, r, c;
} data[112];
struct Mat {
  int n, m;
  long long v[17][17];
  Mat(int tn, int tm) {
    n = tn, m = tm;
    memset(v, 0, sizeof(v));
  }
  Mat operator*(const Mat &t) {
    Mat rst(n, t.m);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < t.m; j++) {
        long long sum = 0;
        for (int k = 0; k < n; k++) {
          sum = sum + (v[i][k] * t.v[k][j]);
          sum = sum % MOD;
        }
        rst.v[i][j] = sum;
      }
    }
    return rst;
  }
  void format() {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (i == j) v[i][j] = 1;
      }
    }
  }
  void out() {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        printf("%lld ", v[i][j]);
      }
      putchar('\n');
    }
  }
};
Mat pow_mod(Mat t, long long k) {
  Mat rst(t.n, t.m);
  rst.format();
  while (k) {
    if (k & 1) rst = rst * t;
    t = t * t;
    k >>= 1;
  }
  return rst;
}
Mat get_mat(int c) {
  Mat m(16, 16);
  m.v[0][0] = m.v[0][1] = 1;
  m.v[15][14] = m.v[15][15] = 1;
  for (int i = 1; i < 15; i++) {
    m.v[i][i - 1] = m.v[i][i] = m.v[i][i + 1] = 1;
  }
  for (int i = 15; i > c; i--) {
    memset(m.v[i], 0, sizeof(m.v[i]));
  }
  m.v[c][c + 1] = 0;
  return m;
}
int main() {
  long long n, k;
  scanf("%lld %lld", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%lld %lld %lld", &data[i].l, &data[i].r, &data[i].c);
  }
  Mat ans(16, 1);
  ans.v[0][0] = 1;
  for (int i = 0; i < n; i++) {
    Mat m = get_mat(data[i].c);
    for (int j = data[i].c + 1; j < 16; j++) {
      ans.v[0][j] = 0;
    }
    if (k <= data[i].r) {
      ans = pow_mod(m, k - data[i].l) * ans;
      break;
    } else {
      ans = pow_mod(m, data[i].r - data[i].l) * ans;
    }
  }
  printf("%lld\n", ans.v[0][0]);
}
