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 MOD = (int)1e9 + 7;
const int N = 2010;
struct data {
  int x, y, c;
  void scan() { scanf("%d%d%d", &x, &y, &c); }
  bool operator<(const data& a) const { return x < a.x; }
} a[N];
int tag[N << 2], ans[N << 2], mx[N << 2], C[N << 2];
set<int> s[N];
vector<int> g[N];
int cnt, b[N], n, k, L, f[N], num[N], CONUM, ANS, cnum[N][N];
void build(int p, int le, int ri) {
  tag[p] = -1;
  if (le == ri) {
    ans[p] = 1ll * (b[le + 1] - b[le]) * (b[f[le]] + 1) % MOD;
    mx[p] = f[le];
    C[p] = b[le + 1] - b[le];
    return;
  }
  int mid = (le + ri) >> 1;
  build(p << 1, le, mid);
  build(p << 1 | 1, mid + 1, ri);
  ans[p] = (ans[p << 1] + ans[p << 1 | 1]) % MOD;
  mx[p] = max(mx[p << 1], mx[p << 1 | 1]);
  C[p] = (C[p << 1] + C[p << 1 | 1]) % MOD;
}
void push(int p) {
  if (tag[p] == -1) return;
  ans[p << 1] = 1ll * C[p << 1] * (b[tag[p]] + 1) % MOD;
  ans[p << 1 | 1] = 1ll * C[p << 1 | 1] * (b[tag[p]] + 1) % MOD;
  mx[p << 1] = mx[p << 1 | 1] = tag[p];
  tag[p << 1] = tag[p << 1 | 1] = tag[p];
  tag[p] = -1;
}
int get(int p, int le, int ri, int k) {
  if (le == ri) return le;
  push(p);
  int mid = (le + ri) >> 1;
  if (mx[p << 1] >= k)
    return get(p << 1, le, mid, k);
  else
    return get(p << 1 | 1, mid + 1, ri, k);
}
void cov(int p, int le, int ri, int ll, int rr, int x) {
  if (ll <= le && ri <= rr) {
    tag[p] = x;
    ans[p] = 1ll * C[p] * (b[x] + 1) % MOD;
    mx[p] = x;
    return;
  }
  push(p);
  int mid = (le + ri) >> 1;
  if (ll <= mid) cov(p << 1, le, mid, ll, rr, x);
  if (rr > mid) cov(p << 1 | 1, mid + 1, ri, ll, rr, x);
  ans[p] = (ans[p << 1] + ans[p << 1 | 1]) % MOD;
  mx[p] = max(mx[p << 1], mx[p << 1 | 1]);
  C[p] = (C[p << 1] + C[p << 1 | 1]) % MOD;
}
void del(int y, int c) {
  cnum[y][c]--;
  if (cnum[y][c]) return;
  s[c].erase(y);
  auto it = s[c].lower_bound(y);
  int pre, nxt;
  if (it == s[c].end())
    nxt = n + 1;
  else
    nxt = *it;
  if (it == s[c].begin())
    pre = 0;
  else
    it--, pre = *it;
  pre++;
  if (mx[1] < pre) return;
  int pos = get(1, 1, cnt, pre);
  if (pos >= nxt) return;
  cov(1, 1, cnt, pos, nxt - 1, pre - 1);
}
int main() {
  scanf("%d%d%d", &n, &k, &L);
  for (int i = 1; i <= n; i++) {
    a[i].scan();
    b[i] = a[i].y;
  }
  sort(b + 1, b + n + 1);
  cnt = 0;
  for (int i = 1; i <= n; i++)
    if (i == 1 || b[i] != b[i - 1]) b[++cnt] = b[i];
  b[0] = -1;
  b[cnt + 1] = L;
  for (int i = 1; i <= n; i++)
    a[i].y = lower_bound(b + 1, b + cnt + 1, a[i].y) - b;
  sort(a + 1, a + n + 1);
  a[0].x = -1;
  for (int i = 1; i <= n; i++) {
    if (i != 1 && a[i].x == a[i - 1].x) continue;
    for (int j = 1; j <= cnt; j++) g[j].clear();
    for (int j = 1; j <= k; j++) s[j].clear();
    for (int j = i; j <= n; j++) {
      s[a[j].c].insert(a[j].y);
      g[a[j].y].push_back(a[j].c);
      cnum[a[j].y][a[j].c]++;
    }
    for (int j = 1; j <= k; j++) num[j] = 0;
    CONUM = 0;
    int now = cnt;
    for (int j = cnt; j; j--) {
      for (; now && CONUM < k;) {
        for (auto co : g[now]) {
          if (!num[co]) CONUM++;
          num[co]++;
        }
        now--;
      }
      if (CONUM < k)
        f[j] = 0;
      else
        f[j] = now + 1;
      for (auto co : g[j]) {
        num[co]--;
        if (!num[co]) CONUM--;
      }
    }
    build(1, 1, cnt);
    ANS =
        (ANS + 1ll * ans[1] * (a[i].x - a[i - 1].x) % MOD * (L - a[n].x)) % MOD;
    for (int j = n; j > i; j--) {
      del(a[j].y, a[j].c);
      if (a[j].x != a[j - 1].x)
        ANS = (ANS + 1ll * ans[1] * (a[i].x - a[i - 1].x) % MOD *
                         (a[j].x - a[j - 1].x)) %
              MOD;
    }
    cnum[a[i].y][a[i].c]--;
  }
  printf("%d\n", ANS);
  return 0;
}