Problem: Shrimpy Duc is a fat and greedy boy who is always hungry. After a while of searching for food to satisfy his never-ending hunger, Shrimpy Duc finds M&M candies lying unguarded on a L × L grid. There are n M&M candies on the grid, the i-th M&M is currently located at (x_i + 0.5, y_i + 0.5), and has color c_i out of a total of k colors (the size of M&Ms are insignificant).

Shrimpy Duc wants to steal a rectangle of M&Ms, specifically, he wants to select a rectangle with integer coordinates within the grid and steal all candies within the rectangle. Shrimpy Duc doesn't need to steal every single candy, however, he would like to steal at least one candy for each color.

In other words, he wants to select a rectangle whose sides are parallel to the coordinate axes and whose left-bottom vertex (X_1, Y_1) and right-top vertex (X_2, Y_2) are points with integer coordinates satisfying 0 ≤ X_1 < X_2 ≤ L and 0 ≤ Y_1 < Y_2 ≤ L, so that for every color 1 ≤ c ≤ k there is at least one M&M with color c that lies within that rectangle.

How many such rectangles are there? This number may be large, so you only need to find it modulo 10^9 + 7.

Input

The first line contains three positive integers n, k, L (1 ≤ k ≤ n ≤ 2 ⋅ 10^3, 1 ≤ L ≤ 10^9 ) — the number of M&Ms, the number of colors and the length of the grid respectively.

The following n points describe the M&Ms. Each line contains three integers x_i, y_i, c_i (0 ≤ x_i, y_i < L, 1 ≤ c_i ≤ k) — the coordinates and color of the i-th M&M respectively. 

Different M&Ms have different coordinates (x_i ≠ x_j or y_i ≠ y_j for every i ≠ j), and for every 1 ≤ c ≤ k there is at least one M&M with color c.

Output

Output a single integer — the number of rectangles satisfying Shrimpy Duc's conditions, modulo 10^9 + 7.

Examples

Input


4 2 4
3 2 2
3 1 1
1 1 1
1 2 1


Output


20


Input


5 3 10
6 5 3
5 3 1
7 9 1
2 3 2
5 0 2


Output


300


Input


10 4 10
5 4 4
0 0 3
6 0 1
3 9 2
8 7 1
8 1 3
2 1 3
6 3 2
3 5 3
4 3 4


Output


226

Note

Grid for the first sample:

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <class t>
inline t read(t &x) {
  char c = getchar();
  bool f = 0;
  x = 0;
  while (!isdigit(c)) f |= c == '-', c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f) x = -x;
  return x;
}
template <class t>
inline void write(t x) {
  if (x < 0)
    putchar('-'), write(-x);
  else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
const int mod = 1e9 + 7, N = 2005;
int n, K, L, ans, first[N], second[N], v[N], qx[N], qy[N], py[N], pl[N], pr[N],
    q[N], mx[N << 2], smx[N << 2], mxs[N << 2], sum[N << 2];
pair<int, int> opp[N];
vector<pair<int, int> > op[N];
struct node {
  int first, second, v;
} opt[N << 2];
void build(int first, int l, int r) {
  mx[first] = 1 << 30;
  smx[first] = -(1 << 30);
  mxs[first] = qy[r + 1] - qy[l];
  sum[first] = 1ll * mx[first] * mxs[first] % mod;
  if (l == r) return;
  int mid = l + r >> 1;
  build(first << 1, l, mid);
  build(first << 1 | 1, mid + 1, r);
}
void modify(int first, int v) {
  sum[first] =
      (sum[first] + 1ll * (v + mod - mx[first]) * mxs[first] % mod) % mod;
  mx[first] = v;
}
void pushdown(int first) {
  if (mx[first << 1] > mx[first]) modify(first << 1, mx[first]);
  if (mx[first << 1 | 1] > mx[first]) modify(first << 1 | 1, mx[first]);
}
void pushup(int first) {
  mx[first] = max(mx[first << 1], mx[first << 1 | 1]);
  smx[first] =
      max(mx[first << 1] == mx[first] ? smx[first << 1] : mx[first << 1],
          mx[first << 1 | 1] == mx[first] ? smx[first << 1 | 1]
                                          : mx[first << 1 | 1]);
  mxs[first] = (mx[first << 1] == mx[first] ? mxs[first << 1] : 0) +
               (mx[first << 1 | 1] == mx[first] ? mxs[first << 1 | 1] : 0);
  sum[first] = (sum[first << 1] + sum[first << 1 | 1]) % mod;
}
void up(int first, int l, int r, int p, int q, int v) {
  if (p <= l && r <= q) {
    if (mx[first] <= v) return;
    if (smx[first] < v) return modify(first, v);
  }
  pushdown(first);
  int mid = l + r >> 1;
  if (p <= mid) up(first << 1, l, mid, p, q, v);
  if (q > mid) up(first << 1 | 1, mid + 1, r, p, q, v);
  pushup(first);
}
int calc(int p) {
  int top = 0;
  for (int i = 1; i <= K; i++) op[i].resize(0);
  for (int i = 1; i <= n; i++)
    if (first[i] >= p) op[v[i]].emplace_back(py[i], first[i]);
  for (int i = 1; i <= K; i++) {
    if (op[i].empty()) return 0;
    sort(op[i].begin(), op[i].end());
    int m = 0, t;
    for (auto j : op[i])
      if (!m || opp[m].first != j.first) opp[++m] = j;
    for (int j = 1; j <= m; j++) pl[j] = 1, pr[j] = *qy;
    t = 0;
    for (int j = 1; j <= m; j++) {
      for (; t && opp[q[t]].second > opp[j].second; t--)
        pr[q[t]] = opp[j].first;
      if (t) pl[j] = opp[q[t]].first;
      q[++t] = j;
    }
    opp[0] = pair<int, int>(1, 0);
    opp[m + 1] = pair<int, int>(*qy, 0);
    for (int j = 1; j <= m; j++) opt[++top] = {pl[j], pr[j], L - opp[j].second};
    for (int j = 1; j <= m + 1; j++)
      opt[++top] = {opp[j - 1].first, opp[j].first, 0};
  }
  sort(opt + 1, opt + 1 + top,
       [](node first, node second) { return first.first < second.first; });
  long long res = 0;
  int pos = 1;
  build(1, 1, (*qy) - 1);
  for (int i = 1; i < *qy; i++) {
    for (; pos <= top && opt[pos].first <= i; pos++)
      up(1, 1, (*qy) - 1, 1, opt[pos].second - 1, opt[pos].v);
    up(1, 1, (*qy) - 1, 1, i, 0);
    res = (res + 1ll * (qy[i + 1] - qy[i]) * sum[1]) % mod;
  }
  return res;
}
signed main() {
  read(n);
  read(K);
  read(L);
  for (int i = 1; i <= n; i++) read(first[i]), read(second[i]), read(v[i]);
  for (int i = 1; i <= n; i++) qx[++*qx] = first[i], qy[++*qy] = second[i];
  qx[++*qx] = -1;
  qy[++*qy] = -1;
  qy[++*qy] = L;
  sort(qx + 1, qx + 1 + *qx);
  sort(qy + 1, qy + 1 + *qy);
  *qx = unique(qx + 1, qx + 1 + *qx) - qx - 1;
  *qy = unique(qy + 1, qy + 1 + *qy) - qy - 1;
  for (int i = 1; i <= n; i++)
    py[i] = lower_bound(qy + 1, qy + 1 + *qy, second[i]) - qy;
  for (int i = 2; i <= *qx; i++)
    ans = (ans + 1ll * (qx[i] - qx[i - 1]) * calc(qx[i])) % mod;
  write((ans + mod) % mod);
}