#include <bits/stdc++.h>
using namespace std;
class matrix {
  long long mat[16][16];

 public:
  int n, m;
  matrix(int a = 1, int b = 1) {
    n = a, m = b;
    memset(mat, 0, sizeof(mat));
  }
  void print() {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) cout << mat[i][j] << ' ';
      cout << "\n";
    }
  }
  matrix operator*(matrix a) {
    matrix res(n, a.m);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < a.m; j++) {
        for (int k = 0; k < m; k++)
          res[i][j] = (res[i][j] + mat[i][k] * a[k][j]) % 1000000007;
      }
    }
    return res;
  }
  long long* operator[](int idx) { return mat[idx]; }
};
matrix modPower(matrix a, long long b) {
  matrix res(a.n, a.m);
  for (int i = 0; i < res.n; i++) res[i][i] = 1;
  while (b) {
    if (b & 1) res = res * a;
    a = a * a;
    b >>= 1;
  }
  return res;
}
vector<matrix> v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 1; i <= 16; i++) {
    matrix a(i, i);
    for (int j = 0; j < i; j++) {
      for (int k = j - 1; k < j + 2; k++) {
        if (k >= 0 && k < i) a[j][k] = 1;
      }
    }
    v.push_back(a);
  }
  int n;
  long long k;
  cin >> n >> k;
  int last = 16;
  matrix a(16);
  a[0][0] = 1;
  for (int i = 0; i < n; i++) {
    long long s, t;
    int y;
    cin >> s >> t >> y;
    matrix b(y + 1);
    for (int j = 0; j < min(y + 1, last); j++) b[j][0] = a[j][0];
    a = modPower(v[y], min(k, t) - s) * b;
    last = y + 1;
  }
  cout << a[0][0] << "\n";
  return 0;
}
