#include <bits/stdc++.h>
using namespace std;
struct Matrix {
  long long val[17][17];
  void init() {
    for (int i = 0; i < 17; i++) {
      for (int j = 0; j < 17; j++) {
        val[i][j] = 0;
      }
      val[i][i] = 1;
    }
  }
  Matrix operator*(const Matrix &a) const {
    Matrix ans;
    for (int i = 0; i < 17; i++) {
      for (int j = 0; j < 17; j++) {
        ans.val[i][j] = 0;
      }
    }
    for (int i = 0; i < 17; i++) {
      for (int j = 0; j < 17; j++) {
        for (int k = 0; k < 17; k++) {
          ans.val[i][j] += val[i][k] * a.val[k][j] % 1000000007;
        }
        ans.val[i][j] %= 1000000007;
      }
    }
    return ans;
  }
};
Matrix pow(Matrix a, long long b) {
  Matrix ans, base = a;
  ans.init();
  while (b) {
    if (b & 1) {
      ans = ans * base;
    }
    base = base * base;
    b >>= 1;
  }
  return ans;
}
int n;
long long k, ans[17], now[17];
int main() {
  scanf("%d%I64d", &n, &k);
  ans[0] = 1;
  for (int t = 1; t <= n; t++) {
    long long a, b;
    int y;
    scanf("%I64d%I64d%d", &a, &b, &y);
    Matrix x;
    for (int j = 0; j < 17; j++) {
      for (int l = 0; l < 17; l++) {
        x.val[l][j] = 0;
      }
    }
    for (int j = 0; j <= y; j++) {
      x.val[j][j] = 1;
      if (j > 0) x.val[j][j - 1] = 1;
      if (j < y) x.val[j][j + 1] = 1;
    }
    if (b > k) b = k;
    Matrix c = pow(x, b - a);
    memset(now, 0, sizeof(now));
    for (int i = 0; i < 17; i++) {
      for (int j = 0; j < 17; j++) {
        now[i] += ans[j] * c.val[i][j] % 1000000007;
      }
    }
    for (int i = 0; i < 17; i++) ans[i] = now[i] % 1000000007;
  }
  printf("%I64d\n", ans[0]);
}
