#include <bits/stdc++.h>
using namespace std;
const int N = 101;
const int MOD = 1000000007;
int n;
long long k;
pair<pair<long long, long long>, int> p[N];
struct mat {
  int q[16][16];
  int sz;
  mat() { memset(q, 0, sizeof q); }
  mat operator*(const mat &rhs) const {
    mat m;
    for (int i = 0; i <= sz; ++i) {
      for (int j = 0; j <= rhs.sz; j++) {
        for (int k = 0; k <= min(sz, rhs.sz); k++) {
          m.q[i][j] =
              (1ll * m.q[i][j] + 1ll * q[i][k] * 1ll * rhs.q[k][j]) % MOD;
        }
      }
    }
    m.sz = max(rhs.sz, sz);
    return m;
  }
};
mat fastPow(mat &a, long long b) {
  if (b == 1) return a;
  mat res = fastPow(a, b / 2);
  res = res * res;
  if (b & 1) return res * a;
  return res;
}
int main() {
  scanf("%d%lld", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%lld%lld%d", &p[i].first.first, &p[i].first.second, &p[i].second);
  }
  mat have = mat();
  have.sz = 1;
  have.q[0][0] = 1;
  for (int it = 0; it < n; it++) {
    mat cur;
    cur.sz = p[it].second;
    for (int i = 0; i <= p[it].second; i++) {
      for (int j = -1; j <= 1; j++) {
        int newY = i + j;
        if (newY >= 0 && newY <= p[it].second) {
          cur.q[i][newY] += 1;
        }
      }
    }
    long long len = min(p[it].first.second, k) - p[it].first.first;
    if (len)
      cur = fastPow(cur, len);
    else {
      break;
    }
    for (int i = 0; i <= 15; i++)
      for (int j = 0; j <= 15; j++) {
        if (i > p[it - 1].second || j > p[it - 1].second) {
          have.q[i][j] = 0;
        }
      }
    have = have * cur;
  }
  printf("%d\n", have.q[0][0]);
  return 0;
}
