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;
const long long MAX = 2005, mod = 1e9 + 7;
using ii = pair<long long, long long>;
ii a[MAX];
ii b[MAX];
long long c[MAX];
long long A[MAX], B[MAX];
vector<long long> pr[MAX], ad[MAX];
long long pre[MAX];
long long cnt[MAX];
ll ST[MAX * 4];
long long MX[MAX * 4], LZ[MAX * 4];
long long val;
long long pos[MAX];
void build(long long id, long long l, long long r) {
  LZ[id] = 0;
  if (l == r) {
    MX[id] = pos[l];
    ST[id] = (B[pos[l]] + 1) * (B[r + 1] - B[r]);
    return;
  }
  long long mid = l + r >> 1;
  build(id << 1 | 1, mid + 1, r);
  build(id << 1, l, mid);
  ST[id] = ST[id << 1] + ST[id << 1 | 1];
  MX[id] = max(MX[id << 1], MX[id << 1 | 1]);
}
bool tt = 0;
void upd(long long x, long long id, long long l, long long r) {
  if (tt) {
    if (r <= x) {
      MX[id] = val;
      ST[id] = (B[val] + 1) * (B[r + 1] - B[l]);
      LZ[id] = val;
      return;
    }
    long long mid = l + r >> 1;
    if (LZ[id]) {
      MX[id << 1] = MX[id << 1 | 1] = LZ[id];
      LZ[id << 1] = LZ[id << 1 | 1] = LZ[id];
      ST[id << 1] = (B[LZ[id]] + 1) * (B[mid + 1] - B[l]);
      ST[id << 1 | 1] = (B[LZ[id]] + 1) * (B[r + 1] - B[mid + 1]);
      LZ[id] = 0;
    }
    upd(x, id << 1, l, mid);
    if (x > mid) upd(x, id << 1 | 1, mid + 1, r);
    ST[id] = ST[id << 1] + ST[id << 1 | 1];
    MX[id] = max(MX[id << 1], MX[id << 1 | 1]);
    return;
  }
  if (l == r) {
    tt = 1;
    MX[id] = val;
    ST[id] = (B[val] + 1) * (B[r + 1] - B[r]);
    return;
  }
  long long mid = l + r >> 1;
  if (LZ[id]) {
    MX[id << 1] = MX[id << 1 | 1] = LZ[id];
    LZ[id << 1] = LZ[id << 1 | 1] = LZ[id];
    ST[id << 1] = (B[LZ[id]] + 1) * (B[mid + 1] - B[l]);
    ST[id << 1 | 1] = (B[LZ[id]] + 1) * (B[r + 1] - B[mid + 1]);
    LZ[id] = 0;
  }
  if (MX[id << 1] > val) upd(x, id << 1, l, mid);
  if (x > mid) upd(x, id << 1 | 1, mid + 1, r);
  ST[id] = ST[id << 1] + ST[id << 1 | 1];
  MX[id] = max(MX[id << 1], MX[id << 1 | 1]);
}
long long N, M;
void down(long long lim, long long vall) {
  if (MX[1] <= vall) return;
  val = vall;
  tt = 0;
  upd(lim, 1, 1, M);
}
multiset<long long> col[MAX];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, K, L;
  cin >> n >> K >> L;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i].first >> a[i].second >> c[i];
    b[i] = ii(a[i].first, i);
  }
  sort(b + 1, b + 1 + n);
  N = 0;
  A[0] = -1;
  for (long long i = 1; i <= n; i++) {
    if (b[i].first != A[N]) A[++N] = b[i].first;
    a[b[i].second].first = N;
    b[i] = ii(a[i].second, i);
  }
  A[N + 1] = L;
  sort(b + 1, b + 1 + n);
  M = 0;
  B[0] = -1;
  for (long long i = 1; i <= n; i++)
    if (b[i].first != B[M]) {
      B[++M] = b[i].first;
      a[b[i].second].second = M;
    } else
      a[b[i].second].second = M;
  B[M + 1] = L;
  for (long long i = 1; i <= n; i++) {
    pr[a[i].first].push_back(i);
    ad[a[i].second].push_back(i);
  }
  ll ans = 0;
  for (long long cs = 1; cs <= N; cs++) {
    memset(pre, 0, sizeof pre);
    memset(cnt, 0, sizeof cnt);
    cnt[0] = K;
    long long poi = 0;
    for (long long i = 1; i <= K; i++) {
      col[i].clear();
      col[i].insert(M + 1);
    }
    for (long long i = 1; i <= M; i++) {
      for (long long u : ad[i])
        if (a[u].first <= cs) {
          cnt[pre[c[u]]]--;
          pre[c[u]] = i;
          cnt[i]++;
          col[c[u]].insert(i);
        }
      while (cnt[poi] == 0) poi++;
      pos[i] = poi;
    }
    build(1, 1, M);
    ans = (ans + ST[1] % mod * (A[cs + 1] - A[cs]) % mod * (A[1] + 1)) % mod;
    for (long long i = 1; i < cs; i++) {
      for (long long u : pr[i]) {
        long long x = c[u];
        col[x].erase(col[x].find(a[u].second));
        auto it = col[x].upper_bound(a[u].second);
        if (it != col[x].begin())
          down((*it) - 1, (*prev(it)));
        else {
          down((*it) - 1, 0);
        }
      }
      ans =
          (ans + ST[1] % mod * (A[cs + 1] - A[cs]) % mod * (A[i + 1] - A[i])) %
          mod;
    }
  }
  ans = (ans % mod + mod) % mod;
  cout << ans << '\n';
}