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;
const int N = 2e3 + 7, mod = 1e9 + 7;
long long ans;
struct node {
  int x, y, c, id;
} s[N];
int n, m, col[N], f[N], tot, L, i, j, k, vis[N], mn[N << 2], len[N << 2],
    mx[N << 2], tag[N << 2], sum[N << 2], head[N], y[N], id[N];
struct List {
  int l[N], r[N];
  void del(int x) {
    r[l[x]] = r[x];
    l[r[x]] = l[x];
  }
} q, nq;
void add(int rt, int v) {
  tag[rt] = max(tag[rt], v);
  sum[rt] = 1LL * len[rt] * v % mod;
  mx[rt] = mn[rt] = v;
}
bool cmpx(node a, node b) { return a.x < b.x; }
bool cmpy(node a, node b) { return a.y < b.y; }
void pushdown(int rt) {
  if (tag[rt])
    add((rt << 1), tag[rt]), add((rt << 1 | 1), tag[rt]), tag[rt] = 0;
}
void update(int rt) {
  sum[rt] = (sum[(rt << 1)] + sum[(rt << 1 | 1)]) % mod;
  mn[rt] = min(mn[(rt << 1)], mn[(rt << 1 | 1)]);
  mx[rt] = max(mx[(rt << 1)], mx[(rt << 1 | 1)]);
}
void build(int rt, int l, int r) {
  tag[rt] = sum[rt] = 0;
  len[rt] = y[r] - y[l - 1];
  if (l == r) return add(rt, f[l]);
  int mid = l + r >> 1;
  build((rt << 1), l, mid);
  build((rt << 1 | 1), mid + 1, r);
  update(rt);
}
void modify(int rt, int l, int r, int pre, int v) {
  if (mn[rt] >= v) return;
  if (mx[rt] <= v && pre <= l) return add(rt, v);
  int mid = l + r >> 1;
  pushdown(rt);
  if (pre <= mid) modify((rt << 1), l, mid, pre, v);
  modify((rt << 1 | 1), mid + 1, r, pre, v);
  update(rt);
}
int main() {
  for (scanf("%d%d%d", &n, &m, &L), i = 1; i <= n; ++i)
    scanf("%d%d%d", &s[i].x, &s[i].y, &s[i].c);
  sort(s + 1, s + n + 1, cmpy);
  for (i = 1; i <= n; ++i)
    nq.l[i] = head[s[i].c], nq.r[head[s[i].c]] = i, head[s[i].c] = i,
    nq.r[i] = n + 1, y[i] = s[i].y, s[i].id = i;
  sort(s + 1, s + n + 1, cmpx);
  s[0].x = s[0].y = -1;
  s[n + 1].x = s[n + 1].y = L;
  y[0] = -1;
  y[n + 1] = L;
  for (int i = 1; i <= n; ++i) {
    if (s[i].x ^ s[i - 1].x) {
      for (memset(vis, 0, sizeof(vis)), memset(col, 0, sizeof(col)), j = i;
           j <= n; ++j)
        col[s[j].id] = s[j].c;
      for (memset(vis, 0, sizeof(vis)), tot = 0, j = k = 1; j <= n; ++j) {
        for (; k <= n && tot < m; ++k)
          if (col[k] && !vis[col[k]]++) ++tot;
        f[j] = (tot < m) ? L : y[k - 1];
        if (col[j] && !--vis[col[j]]) tot--;
      }
      q = nq;
      build(1, 1, n);
      int tot = 0;
      for (j = n; j >= i; --j) {
        ans += (1LL * (y[n] + 1) * L % mod - sum[1]) % mod *
               (s[i].x - s[i - 1].x) % mod * (s[j + 1].x - s[j].x) % mod;
        k = s[j].id;
        modify(1, 1, n, q.l[k] + 1, y[q.r[k]]);
        q.del(k);
      }
      ans = (ans % mod + mod) % mod;
    }
    nq.del(s[i].id);
  }
  printf("%lld\n", ans);
}