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;
using ll = long long;
using Vl = ll[2020 << 2];
using vl = ll[2020];
vector<ll> vx, vy;
Vl Sum, Tag, Max, Min;
vl x, y, c, px, py, cnt, A;
void Merge(int u) {
  Sum[u] = (Sum[u << 1] + Sum[u << 1 | 1]) % 1000000007;
  Max[u] = max(Max[u << 1], Max[u << 1 | 1]);
  Min[u] = min(Min[u << 1], Min[u << 1 | 1]);
}
void Build(int u, int l, int r) {
  Tag[u] = -1;
  if (r - l == 1) {
    Max[u] = Min[u] = A[l];
    Sum[u] = 1ll * (vx.back() - vx[A[l]]) * (vx[r] - vx[l]) % 1000000007;
    return;
  }
  int m = (l + r) >> 1;
  Build(u << 1, l, m);
  Build(u << 1 | 1, m, r);
  Merge(u);
}
void Modify(int u, int l, int r, int v) {
  Tag[u] = Max[u] = Min[u] = v;
  Sum[u] = 1ll * (vx.back() - vx[v]) * (vx[r] - vx[l]) % 1000000007;
}
void Pushdown(int u, int l, int r) {
  if (Tag[u] == -1) return;
  int m = (l + r) >> 1;
  Modify(u << 1, l, m, Tag[u]);
  Modify(u << 1 | 1, m, r, Tag[u]);
  Tag[u] = -1;
}
void Modify(int u, int l, int r, int x, int y, int v) {
  if (l >= y || r <= x || Min[u] >= v) return;
  if (l >= x && r <= y && Max[u] <= v) return Modify(u, l, r, v);
  Pushdown(u, l, r);
  int m = (l + r) >> 1;
  Modify(u << 1, l, m, x, y, v);
  Modify(u << 1 | 1, m, r, x, y, v);
  Merge(u);
}
int main() {
  int n, k, L;
  scanf("%d%d%d", &n, &k, &L);
  for (int i = 0; i < n; ++i)
    scanf("%lld%lld%lld", x + i, y + i, c + i), --c[i], px[i] = i, py[i] = i;
  sort(px, px + n, [&](int i, int j) { return x[i] < x[j]; });
  sort(py, py + n, [&](int i, int j) { return y[i] < y[j]; });
  vx.assign(x, x + n), vy.assign(y, y + n);
  vx.push_back(-1), vx.push_back(L);
  vy.push_back(-1), vy.push_back(L);
  sort(vx.begin(), vx.end());
  sort(vy.begin(), vy.end());
  for (int i = 0; i < n; ++i) x[px[i]] = y[py[i]] = i + 1;
  ll ans = 0;
  for (int u = k; u <= n; ++u) {
    memset(cnt, 0, (k + 1) * sizeof(ll));
    fill(A, A + n, n + 1);
    vector<set<int>> s(k);
    int cur = 0;
    for (int l = 0, i = 0; l < n; ++l) {
      while (i < n && cur < k) {
        int j = px[i];
        if (y[j] <= u && !cnt[c[j]]++) ++cur;
        ++i;
      }
      if (cur == k) A[l] = i;
      int j = px[l];
      if (y[j] <= u && !--cnt[c[j]]) --cur;
    }
    Build(1, 0, n);
    for (int i = 0; i < n; ++i)
      if (y[i] <= u) s[c[i]].insert(x[i]);
    ll res = 0;
    for (int d = 0; d + 1 <= u; ++d) {
      res = (res + (vy[d + 1] - vy[d]) * Sum[1]) % 1000000007;
      int j = py[d];
      auto it = s[c[j]].erase(s[c[j]].find(x[j]));
      int r = it == s[c[j]].end() ? n + 1 : *it;
      int l = it == s[c[j]].begin() ? 0 : *prev(it);
      Modify(1, 0, n, l, x[j], r);
    }
    ans = (ans + res * (vy[u + 1] - vy[u])) % 1000000007;
  }
  cout << ans << endl;
  return 0;
}