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 long long mod = 1e9 + 7;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, k, L, x[4086], y[4086], cnt[4086], f[4086], lenx, leny, _pre, _nxt;
struct node {
  int x, y, c;
} nd[4086];
bool cmp1(node a, node b) { return a.x < b.x || (a.x == b.x && a.y < b.y); }
bool cmp2(node a, node b) { return a.y > b.y || (a.y == b.y && a.x < b.x); }
int del(int &tp, int sum) {
  int o;
  for (o = tp; nd[o].y == nd[tp].y && o <= n; o++) {
    cnt[nd[o].c]--;
    if (cnt[nd[o].c] == 0) sum--;
  }
  if (sum < k) return 0;
  return o;
}
void add(int tp) {
  int o;
  for (o = tp; nd[o].y == nd[tp].y; o++) cnt[nd[o].c]++;
  return;
}
long long sum[4086 << 2], mx[4086 << 2], mn[4086 << 2];
int tag[4086 << 2];
void build(int tot, int l, int r) {
  if (l == r) {
    if (f[l] != leny)
      sum[tot] = 1ll * (y[f[l]] + 1) * (y[l] - y[l - 1]) % mod;
    else
      sum[tot] = 1ll * y[f[l]] * (y[l] - y[l - 1]) % mod;
    mx[tot] = mn[tot] = f[l];
    tag[tot] = 0;
    return;
  }
  int mid = l + r >> 1;
  build(tot << 1, l, mid);
  build(tot << 1 | 1, mid + 1, r);
  tag[tot] = 0;
  sum[tot] = (sum[tot << 1] + sum[tot << 1 | 1]) % mod;
  mx[tot] = max(mx[tot << 1], mx[tot << 1 | 1]);
  mn[tot] = min(mn[tot << 1], mn[tot << 1 | 1]);
}
void pushdown(int tot, int l, int r) {
  int mid = l + r >> 1;
  if (!tag[tot]) return;
  int t = tag[tot];
  tag[tot] = 0;
  int ls = tot << 1, rs = tot << 1 | 1;
  tag[ls] = tag[rs] = t;
  if (t != leny) {
    sum[ls] = 1ll * (y[t] + 1) * (y[mid] - y[l - 1]) % mod;
    sum[rs] = 1ll * (y[t] + 1) * (y[r] - y[mid]) % mod;
  } else {
    sum[ls] = 1ll * y[t] * (y[mid] - y[l - 1]) % mod;
    sum[rs] = 1ll * y[t] * (y[r] - y[mid]) % mod;
  }
  mx[ls] = mx[rs] = mn[ls] = mn[rs] = t;
  return;
}
void modify(int tot, int l, int r, int L, int R, int val) {
  if (L > R) return;
  if (L <= l && r <= R) {
    if (mn[tot] >= val) return;
    if (mx[tot] <= val) {
      tag[tot] = val;
      if (val != leny)
        sum[tot] = 1ll * (y[val] + 1) * (y[r] - y[l - 1]) % mod;
      else
        sum[tot] = 1ll * y[val] * (y[r] - y[l - 1]) % mod;
      mx[tot] = val, mn[tot] = val;
      return;
    }
    int mid = l + r >> 1;
    modify(tot << 1, l, mid, L, R, val);
    modify(tot << 1 | 1, mid + 1, r, L, R, val);
  }
  pushdown(tot, l, r);
  int mid = l + r >> 1;
  if (L <= mid) modify(tot << 1, l, mid, L, R, val);
  if (R > mid) modify(tot << 1 | 1, mid + 1, r, L, R, val);
  sum[tot] = (sum[tot << 1] + sum[tot << 1 | 1]) % mod;
  mx[tot] = max(mx[tot << 1], mx[tot << 1 | 1]);
  mn[tot] = min(mn[tot << 1], mn[tot << 1 | 1]);
}
multiset<int> col[4086];
multiset<int>::iterator it;
int main() {
  int i, j, o, nxt, qsumy, ans, w;
  n = read(), k = read(), L = read();
  for (i = 1; i <= n; i++) {
    nd[i].x = read(), nd[i].y = read(), nd[i].c = read();
    x[i] = nd[i].x, y[i] = nd[i].y;
  }
  sort(nd + 1, nd + n + 1, cmp1);
  sort(x + 1, x + n + 1);
  sort(y + 1, y + n + 1);
  lenx = unique(x + 1, x + n + 1) - x - 1;
  leny = unique(y + 1, y + n + 1) - y - 1;
  for (i = 1; i <= n; i++)
    col[nd[i].c].insert(lower_bound(y + 1, y + leny + 1, nd[i].y) - y);
  for (i = 1; i <= k; i++) col[i].insert(0), col[i].insert(leny + 1);
  y[++leny] = L + 1;
  x[lenx + 1] = L;
  x[0] = -1;
  y[0] = -1;
  int st = 1, tot, tp;
  ans = 0;
  for (i = 1; i <= lenx; i++) {
    while (nd[st].x < x[i]) {
      col[nd[st].c].erase(
          col[nd[st].c].find(lower_bound(y + 1, y + leny + 1, nd[st].y) - y));
      st++;
    }
    for (j = 1; j <= leny - 1; j++) f[j] = 0;
    for (j = 1; j <= n; j++) cnt[j] = 0;
    tot = 0;
    tp = st;
    sort(nd + st, nd + n + 1, cmp2);
    for (j = leny - 1; j >= lower_bound(y + 1, y + leny + 1, nd[st].y) - y; j--)
      f[j] = leny;
    for (j = st; j <= n; j = nxt) {
      for (o = j; nd[o].y == nd[j].y && o <= n; o++) {
        cnt[nd[o].c]++;
        if (cnt[nd[o].c] == 1) tot++;
      }
      nxt = o;
      if (tot == k) {
        f[lower_bound(y + 1, y + leny + 1, nd[j].y) - y] =
            lower_bound(y + 1, y + leny + 1, nd[tp].y) - y;
        while (tp < j && (o = del(tp, tot)))
          tp = o, f[lower_bound(y + 1, y + leny + 1, nd[j].y) - y] =
                      lower_bound(y + 1, y + leny + 1, nd[tp].y) - y;
        if (tp < j) add(tp);
        tot = k;
      } else
        f[lower_bound(y + 1, y + leny + 1, nd[j].y) - y] = leny;
      if (nxt <= n)
        for (w = lower_bound(y + 1, y + leny + 1, nd[j].y) - y - 1;
             w > lower_bound(y + 1, y + leny + 1, nd[nxt].y) - y; w--)
          f[w] = f[w + 1];
      else
        for (w = lower_bound(y + 1, y + leny + 1, nd[j].y) - y - 1; w > 0; w--)
          f[w] = f[w + 1];
    }
    build(1, 1, leny - 1);
    sort(nd + st, nd + n + 1, cmp1);
    qsumy = sum[1];
    qsumy = (1ll * (y[leny - 1] + 1) * (L + 1) % mod - qsumy) % mod;
    qsumy = 1ll * (x[i] - x[i - 1]) * (L - x[lenx]) % mod * qsumy % mod;
    ans = (ans + qsumy) % mod;
    int en = lenx;
    for (j = n; j >= st; j = o) {
      for (o = j; nd[o].x == nd[j].x && o > 0; o--)
        col[nd[o].c].erase(
            col[nd[o].c].find(lower_bound(y + 1, y + leny + 1, nd[o].y) - y));
      for (o = j; nd[o].x == nd[j].x && o > 0; o--) {
        it = col[nd[o].c].lower_bound(
            lower_bound(y + 1, y + leny + 1, nd[o].y) - y);
        _nxt = (*it);
        if ((*it) > lower_bound(y + 1, y + leny + 1, nd[o].y) - y) it--;
        _pre = (*it) + 1;
        int xxxx = lower_bound(y + 1, y + leny + 1, nd[o].y) - y;
        modify(1, 1, leny - 1, _pre,
               lower_bound(y + 1, y + leny + 1, nd[o].y) - y, _nxt);
      }
      en--;
      qsumy = sum[1];
      qsumy = (1ll * (y[leny - 1] + 1) * (L + 1) % mod - qsumy) % mod;
      qsumy = 1ll * (x[i] - x[i - 1]) * (x[en + 1] - x[en]) % mod * qsumy % mod;
      ans = (ans + qsumy) % mod;
    }
    for (j = st; j <= n; j++)
      col[nd[j].c].insert(lower_bound(y + 1, y + leny + 1, nd[j].y) - y);
  }
  ans = (ans + mod) % mod;
  printf("%lld\n", (ans + mod) % mod);
}