Okabe likes to take walks but knows that spies from the Organization could be anywhere; that's why he wants to know how many different walks he can take in his city safely. Okabe's city can be represented as all points (x, y) such that x and y are non-negative. Okabe starts at the origin (point (0, 0)), and needs to reach the point (k, 0). If Okabe is currently at the point (x, y), in one step he can go to (x + 1, y + 1), (x + 1, y), or (x + 1, y - 1).

Additionally, there are n horizontal line segments, the i-th of which goes from x = ai to x = bi inclusive, and is at y = ci. It is guaranteed that a1 = 0, an ≤ k ≤ bn, and ai = bi - 1 for 2 ≤ i ≤ n. The i-th line segment forces Okabe to walk with y-value in the range 0 ≤ y ≤ ci when his x value satisfies ai ≤ x ≤ bi, or else he might be spied on. This also means he is required to be under two line segments when one segment ends and another begins.

Okabe now wants to know how many walks there are from the origin to the point (k, 0) satisfying these conditions, modulo 109 + 7.

Input

The first line of input contains the integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 1018) — the number of segments and the destination x coordinate.

The next n lines contain three space-separated integers ai, bi, and ci (0 ≤ ai < bi ≤ 1018, 0 ≤ ci ≤ 15) — the left and right ends of a segment, and its y coordinate.

It is guaranteed that a1 = 0, an ≤ k ≤ bn, and ai = bi - 1 for 2 ≤ i ≤ n.

Output

Print the number of walks satisfying the conditions, modulo 1000000007 (109 + 7).

Examples

Input

1 3
0 3 3


Output

4


Input

2 6
0 3 0
3 10 2


Output

4

Note

<image>

The graph above corresponds to sample 1. The possible walks are:

  * <image>
  * <image>
  * <image>
  * <image>

<image>

The graph above corresponds to sample 2. There is only one walk for Okabe to reach (3, 0). After this, the possible walks are:

  * <image>
  * <image>
  * <image>
  * <image>
#include <bits/stdc++.h>
using namespace std;
const long long base = 1e9 + 7;
long long n, k;
struct line {
  long long a, b, y;
} a[101];
struct matrix {
  long long val[16][16];
  matrix() { memset(val, 0, sizeof(val)); }
};
struct matran {
  long long val[16];
  matran() { memset(val, 0, sizeof(val)); }
};
matrix res, tmp, A;
matran cur;
inline matrix operator*(const matrix &x, const matrix &y) {
  for (int i = 0; i <= 15; i++) {
    for (int j = 0; j <= 15; j++) {
      tmp.val[i][j] = 0;
      for (int p = 0; p <= 15; p++) {
        tmp.val[i][j] =
            (tmp.val[i][j] + (x.val[i][p] * y.val[p][j]) % base) % base;
      }
    }
  }
  return tmp;
}
inline matran operator*(const matrix &x, const matran &y) {
  for (int i = 0; i <= 15; i++) {
    cur.val[i] = 0;
    for (int j = 0; j <= 15; j++) {
      cur.val[i] = (cur.val[i] + (x.val[i][j] * y.val[j]) % base) % base;
    }
  }
  return cur;
}
inline void pw(long long p) {
  if (p == 1) {
    res = A;
    return;
  }
  for (int i = 0; i <= 15; i++) res.val[i][i] = 1;
  for (; p; p /= 2, A = A * A) {
    if (p & 1) res = res * A;
  }
}
matran B, ans;
matrix duc;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].a >> a[i].b >> a[i].y;
  }
  B.val[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 15; j++) {
      if (j > a[i].y) B.val[j] = 0;
    }
    if (a[i].a >= k) break;
    for (int p = 0; p <= 15; p++) {
      for (int q = 0; q <= 15; q++) {
        A.val[p][q] = 0;
      }
    }
    for (int j = a[i].y; j >= 0; j--) {
      if (j + 1 <= a[i].y) A.val[j][j + 1] = 1;
      A.val[j][j] = 1;
      if (j - 1 >= 0) A.val[j][j - 1] = 1;
    }
    memset(res.val, 0, sizeof(res.val));
    if (a[i].b >= k)
      pw(k - a[i].a);
    else
      pw(a[i].b - a[i].a);
    B = res * B;
  }
  cout << B.val[0];
}
