#include <bits/stdc++.h>
using namespace std;
vector<vector<long long int> > pos;
long long int arr[110][3];
vector<vector<long long int> > matrix_exp(vector<vector<long long int> > a,
                                          long long int n);
vector<vector<long long int> > matrix_mul(vector<vector<long long int> > a,
                                          vector<vector<long long int> > b) {
  vector<vector<long long int> > ret;
  for (long long int i = 0; i < a.size(); i++) {
    vector<long long int> temp;
    for (long long int j = 0; j < b[0].size(); j++) {
      long long int val = 0;
      for (long long int k = 0; k < a[i].size(); k++) {
        val = (val +
               ((a[i][k] % 1000000007) * (b[k][j] % 1000000007)) % 1000000007) %
              1000000007;
      }
      temp.push_back(val);
    }
    ret.push_back(temp);
  }
  return ret;
}
vector<vector<long long int> > matrix_exp(vector<vector<long long int> > a,
                                          long long int n) {
  if (n == 1) return a;
  if (n % 2 == 1) return matrix_mul(matrix_exp(a, n - 1), a);
  vector<vector<long long int> > temp = matrix_exp(a, n / 2);
  return matrix_mul(temp, temp);
}
int main() {
  ios::sync_with_stdio(false);
  long long int n, k;
  cin >> n >> k;
  vector<long long int> temp;
  for (long long int i = 0; i < 16; i++) temp.push_back(0);
  temp[0] = 1;
  pos.push_back(temp);
  for (long long int i = 0; i < n; i++)
    cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
  for (long long int i = 0; i < n; i++) {
    long long int a, b, c;
    a = arr[i][0];
    b = arr[i][1];
    c = arr[i][2];
    b = min(b, k);
    if (b == a) continue;
    temp.clear();
    for (long long int j = 0; j <= c; j++) temp.push_back(pos[0][j]);
    vector<vector<long long int> > temp1, temp2, temp3;
    temp1.push_back(temp);
    for (long long int j = 0; j <= c; j++) {
      temp.clear();
      for (long long int z = 0; z <= c; z++) {
        if (abs(z - j) <= 1)
          temp.push_back(1);
        else
          temp.push_back(0);
      }
      temp2.push_back(temp);
    }
    if (b - a > 0) {
      temp3 = matrix_exp(temp2, b - a);
      temp1 = matrix_mul(temp1, temp3);
    }
    pos[0] = temp1[0];
    while (pos[0].size() != 16) pos[0].push_back(0);
  }
  cout << pos[0][0] << endl;
  return (0);
}
