#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1, -1, -1, 1, 1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
template <class T>
inline T biton(T n, T pos) {
  return n | ((T)1 << pos);
}
template <class T>
inline T bitoff(T n, T pos) {
  return n & ~((T)1 << pos);
}
template <class T>
inline T ison(T n, T pos) {
  return (bool)(n & ((T)1 << pos));
}
template <class T>
inline T gcd(T a, T b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <typename T>
string NumberToString(T Number) {
  ostringstream second;
  second << Number;
  return second.str();
}
inline int nxt() {
  int aaa;
  scanf("%d", &aaa);
  return aaa;
}
inline long long int lxt() {
  long long int aaa;
  scanf("%lld", &aaa);
  return aaa;
}
inline double dxt() {
  double aaa;
  scanf("%lf", &aaa);
  return aaa;
}
template <class T>
inline T bigmod(T p, T e, T m) {
  T ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % m;
    p = (p * p) % m;
  }
  return (T)ret;
}
struct matrix {
  long long int mat[16][16];
  int row, clm;
  matrix() { memset(mat, 0, sizeof mat); }
  matrix(int a, int b) {
    row = a;
    clm = b;
    memset(mat, 0, sizeof mat);
  }
  void identity() {
    for (int i = 0; i < row; i++) mat[i][i] = 1;
  }
  void print() {
    for (int i = 0; i < row; i++) {
      for (int j = 0; j < clm; j++) printf("%lld ", mat[i][j]);
      printf("\n");
    }
  }
};
matrix mul(matrix a, matrix b) {
  matrix c;
  c.row = a.row;
  c.clm = b.clm;
  for (int i = 0; i < c.row; i++)
    for (int j = 0; j < c.clm; j++) {
      c.mat[i][j] = 0;
      for (int k = 0; k < a.clm; k++)
        c.mat[i][j] = (c.mat[i][j] +
                       (a.mat[i][k] % 1000000007 * b.mat[k][j] % 1000000007) %
                           1000000007) %
                      1000000007;
    }
  return c;
}
matrix power(matrix p, long long int e) {
  matrix ret(p.row, p.clm);
  ret.identity();
  while (e) {
    if (e & 1) ret = mul(p, ret);
    p = mul(p, p);
    e >>= 1;
  }
  return ret;
}
int main() {
  matrix base(16, 16);
  matrix init(16, 1);
  init.mat[0][0] = 1;
  matrix res(16, 1);
  res.mat[0][0] = 1;
  int n = nxt();
  long long int k = lxt();
  for (int i = 0; i < n; i++) {
    long long int a = lxt();
    long long int b = lxt();
    int c = nxt();
    memset(init.mat, 0, sizeof(init.mat));
    for (int i = 0; i <= c; i++) init.mat[i][0] = res.mat[i][0];
    memset(base.mat, 0, sizeof(base.mat));
    for (int i = 0; i <= c; i++) {
      base.mat[i][i] = 1;
      if (i + 1 <= c) base.mat[i][i + 1] = 1;
      if (i) base.mat[i][i - 1] = 1;
    }
    if (b > k) b = k;
    matrix tmp = power(base, b - a);
    res = mul(tmp, init);
    if (b == k) break;
  }
  printf("%lld\n", res.mat[0][0]);
  return 0;
}
