#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const long long linf = (long long)1e18;
const double eps = (double)1e-8;
const int mod = (int)1e9 + 7;
const int maxn = (int)1e5 + 5;
const int MX = 16;
void multiply(vector<vector<int> > a, vector<vector<int> > b,
              vector<vector<int> >& res) {
  if (a.size() == 0 || b.size() == 0 || a[0].size() == 0 || b[0].size() == 0 ||
      a[0].size() != b.size())
    return;
  res.resize(a.size());
  for (int i = (0); i < (int)(res.size()); ++i) {
    res[i].resize(b[0].size());
  }
  for (int i = (0); i < (int)(res.size()); ++i) {
    for (int j = (0); j < (int)(res[i].size()); ++j) {
      res[i][j] = 0;
      for (int k = (0); k < (int)(a[0].size()); ++k) {
        res[i][j] = (res[i][j] + 1ll * a[i][k] * b[k][j]) % mod;
      }
    }
  }
}
vector<vector<int> > mult;
vector<vector<int> > buff[222];
void stp(long long st, vector<vector<int> >& res, int u = 0) {
  if (st == 0) {
    res.resize(MX);
    for (int i = (0); i < (int)(MX); ++i) {
      res[i].resize(MX);
      for (int j = (0); j < (int)(MX); ++j) res[i][j] = 0;
      res[i][i] = 1;
    }
    return;
  }
  if (st & 1) {
    vector<vector<int> >& tmp = buff[u];
    stp(st - 1, tmp, u + 1);
    multiply(tmp, mult, res);
  } else {
    vector<vector<int> >& tmp = buff[u];
    stp(st / 2, tmp, u + 1);
    multiply(tmp, tmp, res);
  }
}
long long n, k, a[111], b[111], c[111];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = (1); i <= (int)(n); ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }
  b[n] = k;
  vector<vector<int> > x;
  x.push_back(vector<int>(MX));
  x[0][0] = 1;
  for (int i = (1); i <= (int)(n); ++i) {
    mult = vector<vector<int> >(MX);
    for (int j = (0); j < (int)(MX); ++j) {
      mult[j] = vector<int>(MX);
      for (int k = (0); k < (int)(MX); ++k) mult[j][k] = 0;
    }
    for (int j = (c[i] + 1); j <= (int)(MX - 1); ++j) {
      x[0][j] = 0;
    }
    for (int j = (0); j <= (int)(c[i]); ++j) {
      mult[j][j] = 1;
      if (j < c[i]) mult[j][j + 1] = 1;
      if (j != 0) mult[j][j - 1] = 1;
    }
    vector<vector<int> > res, newx;
    stp(b[i] - a[i], res);
    multiply(x, res, newx);
    x = newx;
  }
  cout << x[0][0] << endl;
  return 0;
}
