#include <bits/stdc++.h>
using namespace std;
struct Mat {
  int n, m, s[20][20];
  inline void init(int x, int y) {
    n = x;
    m = y;
    memset(s, 0, sizeof s);
  }
  inline Mat operator*(const Mat& b) {
    Mat c;
    c.init(n, b.m);
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < b.m; ++j)
        for (int k = 0; k < m; ++k)
          c.s[i][j] = (c.s[i][j] + (long long)s[i][k] * b.s[k][j]) % 1000000007;
    return c;
  }
} a;
inline Mat Trans(int p) {
  Mat c;
  c.init(16, 16);
  for (int i = 0; i <= p; ++i) {
    c.s[i][i] = 1;
    if (i) c.s[i][i - 1] = 1;
    if (i < p) c.s[i][i + 1] = 1;
  }
  return c;
}
inline void pow(Mat x, long long k, Mat& s) {
  for (; k; x = x * x, k >>= 1) k& 1 ? s = s * x : s;
}
long long n, k;
int c;
int main() {
  scanf("%lld%lld", &n, &k);
  a.init(1, 16);
  a.s[0][0] = 1;
  for (long long l, r; n--;) {
    scanf("%lld%lld%d", &l, &r, &c);
    if (r > k) r = k;
    pow(Trans(c), r - l, a);
    if (r == k) break;
  }
  printf("%d\n", a.s[0][0]);
}
