#include <bits/stdc++.h>
using namespace std;
const int mod = (long long)(1e9 + 7);
int n;
long long k, a[111], b[111], c[111], m[17][17], fm[17][17], f[17][2];
void resetM(int c) {
  for (int i = 1; i <= 16; i++) {
    for (int j = 1; j <= 16; j++) {
      m[i][j] = 0;
      fm[i][j] = 0;
    }
  }
  int up = 16 - c + 1;
  for (int i = 16; i >= up; i--) {
    int s = i - 1, e = i + 1;
    if (s < 0) s = 1;
    if (e > 16) e = 16;
    if (i == up) s = i;
    for (int j = s; j <= e; j++) {
      m[i][j] = 1;
      fm[i][j] = 1;
    }
  }
}
void mul(long long a[17][17], long long b[17][17]) {
  long long c[17][17];
  for (int i = 1; i <= 16; i++) {
    for (int j = 1; j <= 16; j++) {
      c[i][j] = 0;
      for (int k = 1; k <= 16; k++) {
        c[i][j] = (c[i][j] + (1LL * a[i][k] * b[k][j]) % mod) % mod;
      }
    }
  }
  for (int i = 1; i <= 16; i++)
    for (int j = 1; j <= 16; j++) a[i][j] = c[i][j];
}
void mul2(long long a[17][17], long long b[17][2]) {
  long long c[17][2];
  for (int i = 1; i <= 16; i++) {
    c[i][1] = 0;
    for (int k = 1; k <= 16; k++) {
      c[i][1] = (c[i][1] + (1LL * a[i][k] * b[k][1]) % mod) % mod;
    }
  }
  for (int i = 1; i <= 16; i++) b[i][1] = c[i][1];
}
void power(long long cof) {
  --cof;
  if (cof < 0) return;
  while (cof) {
    if (cof & 1) mul(m, fm);
    mul(fm, fm);
    cof >>= 1;
  }
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    ++c[i];
  }
  for (int i = 1; i <= 16; i++) f[i][1] = 0;
  f[16][1] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 16 - c[i]; j++) f[j][1] = 0;
    resetM(c[i]);
    b[i] = min(b[i], k);
    long long t = (b[i] - a[i] + 1);
    power(t - 1);
    mul2(m, f);
    if (b[i] == k) break;
  }
  cout << f[16][1] << endl;
  return 0;
}
