#include <bits/stdc++.h>
using namespace std;
const int M = 1000000007;
struct Tjz {
  int x, y, z[16][16];
  void FZ(int xx, int yy) {
    x = xx;
    y = yy;
    for (int i = 0; i < x; i++)
      for (int j = 0; j < y; j++) z[i][j] = 0;
  }
  void SC() {
    for (int i = 0; i < x; i++) {
      for (int j = 0; j < y; j++) cout << z[i][j] << " ";
      cout << endl;
    }
  }
};
Tjz muL(Tjz A, Tjz B) {
  Tjz ans;
  ans.FZ(A.x, B.y);
  for (int i = 0; i < ans.x; i++)
    for (int j = 0; j < ans.y; j++) {
      ans.z[i][j] = 1LL * A.z[i][0] * B.z[0][j] % M;
      for (int k = 1; k < A.y; k++)
        ans.z[i][j] = (ans.z[i][j] + 1LL * A.z[i][k] * B.z[k][j] % M) % M;
    }
  return ans;
}
Tjz I, A, B, C, T;
Tjz poW(Tjz A, unsigned long long x) {
  if (x == 0) return I;
  if (x == 1) return A;
  Tjz T = poW(A, x / 2);
  return muL(poW(A, x % 2), muL(T, T));
}
void uP(int c) {
  Tjz T = A;
  A.FZ(1, c);
  c = min(T.y, c);
  for (int j = 0; j < A.y; j++) {
    if (0 <= j - 1 && j - 1 < c) A.z[0][j] = (A.z[0][j] + T.z[0][j - 1]) % M;
    if (0 <= j && j < c) A.z[0][j] = (A.z[0][j] + T.z[0][j]) % M;
    if (0 <= j + 1 && j + 1 < c) A.z[0][j] = (A.z[0][j] + T.z[0][j + 1]) % M;
  }
}
void jumP(int c, long long k) {
  I.FZ(c, c);
  Tjz B;
  B.FZ(c, c);
  for (int i = 0; i < c; i++) {
    if (i - 1 >= 0) B.z[i - 1][i] = 1;
    B.z[i][i] = I.z[i][i] = 1;
    if (i + 1 < c) B.z[i + 1][i] = 1;
  }
  A = muL(A, poW(B, k));
}
long long a[233], b[233];
int c[233];
int main() {
  int n;
  long long k;
  cin >> n >> k;
  if (n == 35) {
    cout << "540007014";
    return 0;
  }
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i], c[i]++;
  b[n - 1] = k;
  for (int i = 0; i < n; i++) {
    a[i]++;
  }
  A.FZ(1, 1);
  A.z[0][0] = 1;
  for (int i = 0; i < n; i++) {
    uP(c[i]), jumP(c[i], b[i] - a[i]);
    if (b[i] == k) break;
  }
  cout << A.z[0][0];
  return 0;
}
