#include <bits/stdc++.h>
using namespace std;
int quick_pow(int a, int b, int MOD) {
  a %= MOD;
  int res = 1;
  while (b) {
    if (b & 1) res = (res * a) % MOD;
    b /= 2;
    a = (a * a) % MOD;
  }
  return res;
}
const int maxn = 200 + 10;
const int MOD = 1e9 + 7;
int N;
typedef struct MM {
  long long mat[20][20];
  void Init() { memset(mat, 0, sizeof(mat)); }
  void EMat() {
    for (int i = 0; i <= N; i++) mat[i][i] = 1;
  }
} Mat;
Mat multi(Mat a, Mat b) {
  Mat res;
  res.Init();
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      for (int k = 0; k <= N; k++) {
        res.mat[i][j] += a.mat[i][k] * b.mat[k][j] % MOD;
        res.mat[i][j] %= MOD;
      }
    }
  }
  return res;
}
Mat Pow(Mat a, long long n) {
  Mat res;
  res.Init();
  res.EMat();
  while (n) {
    if (n & 1) res = multi(res, a);
    n /= 2;
    a = multi(a, a);
  }
  return res;
}
long long a[maxn], b[maxn], dp[20], f[20];
int c[maxn];
int main() {
  int i, j, n;
  long long k;
  scanf("%d%I64d", &n, &k);
  for (i = 1; i <= n; i++) {
    scanf("%I64d%I64d%d", &a[i], &b[i], &c[i]);
  }
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  a[0] = 0;
  for (i = 1; i <= n; i++) {
    for (j = 19; j > c[i]; j--) dp[j] = 0;
    Mat ori;
    ori.Init();
    for (j = 0; j <= c[i]; j++) {
      if (j > 0) ori.mat[j - 1][j] = 1;
      if (j < c[i]) ori.mat[j + 1][j] = 1;
      ori.mat[j][j] = 1;
    }
    N = c[i];
    long long K;
    if (b[i] < k)
      K = b[i] - a[i];
    else
      K = k - a[i];
    Mat res = Pow(ori, K);
    memset(f, 0, sizeof(f));
    for (j = 0; j <= c[i]; j++) {
      for (int q = 0; q <= c[i]; q++) {
        f[j] += res.mat[q][j] * dp[q] % MOD;
        f[j] %= MOD;
      }
    }
    for (j = 0; j <= c[i]; j++) dp[j] = f[j];
    if (k <= b[i]) break;
  }
  printf("%I64d\n", dp[0]);
  return 0;
}
