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 + 10;
const int mod = 1e9 + 7;
int qpow(int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1) ret = 1ll * ret * a % mod;
    a = 1ll * a * a % mod;
    b >>= 1;
  }
  return ret;
}
int n, k, l, x[N], y[N], c[N], stx[N], tpx, sty[N], tpy, lenx[N], leny[N],
    sleny[N], mx[N << 2], se[N << 2], sum[N << 2], tag[N << 2], sumy[N << 2];
multiset<int> pos[N];
vector<int> vec[N];
void up(int x) {
  sum[x] = (sum[(x << 1)] + sum[(x << 1 | 1)]) % mod;
  mx[x] = max(mx[(x << 1)], mx[(x << 1 | 1)]);
  se[x] = max(mx[x] == mx[(x << 1)] ? se[(x << 1)] : mx[(x << 1)],
              mx[x] == mx[(x << 1 | 1)] ? se[(x << 1 | 1)] : mx[(x << 1 | 1)]);
  sumy[x] = 0;
  if (mx[x] == mx[(x << 1)]) sumy[x] = (sumy[x] + sumy[(x << 1)]) % mod;
  if (mx[x] == mx[(x << 1 | 1)]) sumy[x] = (sumy[x] + sumy[(x << 1 | 1)]) % mod;
}
void build(int x = 1, int l = 1, int r = tpy) {
  tag[x] = 0;
  if (l == r) {
    mx[x] = l + 1;
    se[x] = -1e9;
    sum[x] = 1ll * leny[l] * sleny[l + 1] % mod;
    sumy[x] = leny[l];
    return;
  }
  int mid = (l + r) >> 1;
  build((x << 1), l, mid);
  build((x << 1 | 1), mid + 1, r);
  up(x);
}
void mdf(int x, int v) {
  sum[x] = (sum[x] - 1ll * sleny[mx[x]] * sumy[x]) % mod;
  if (sum[x] < 0) sum[x] += mod;
  mx[x] += v;
  tag[x] += v;
  sum[x] = (sum[x] + 1ll * sleny[mx[x]] * sumy[x]) % mod;
}
void down(int x) {
  if (tag[x]) {
    int tmp = max(mx[(x << 1)], mx[(x << 1 | 1)]);
    if (mx[(x << 1)] == tmp) mdf((x << 1), tag[x]);
    if (mx[(x << 1 | 1)] == tmp) mdf((x << 1 | 1), tag[x]);
    tag[x] = 0;
  }
}
void modify(int L, int R, int v, int x = 1, int l = 1, int r = tpy) {
  if (L > R || mx[x] <= v) return;
  if (L <= l && r <= R && se[x] < v) return mdf(x, v - mx[x]);
  down(x);
  int mid = (l + r) >> 1;
  if (L <= mid) modify(L, R, v, (x << 1), l, mid);
  if (R > mid) modify(L, R, v, (x << 1 | 1), mid + 1, r);
  up(x);
}
void print(int x = 1, int l = 1, int r = tpy) {
  if (l == r) {
    cerr << mx[x] << ' ';
    return;
  }
  down(x);
  int mid = (l + r) >> 1;
  print((x << 1), l, mid);
  print((x << 1 | 1), mid + 1, r);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k >> l;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i] >> c[i];
    stx[++tpx] = x[i];
    sty[++tpy] = y[i];
  }
  stx[++tpx] = sty[++tpy] = l;
  sort(stx + 1, stx + tpx + 1);
  tpx = unique(stx + 1, stx + tpx + 1) - stx - 1;
  sort(sty + 1, sty + tpy + 1);
  tpy = unique(sty + 1, sty + tpy + 1) - sty - 1;
  stx[0] = sty[0] = -1;
  for (int i = 0; i < tpx; i++) lenx[i] = stx[i + 1] - stx[i];
  for (int i = 0; i < tpy; i++) leny[i] = sty[i + 1] - sty[i];
  for (int i = 1; i <= n; i++) {
    x[i] = lower_bound(stx + 1, stx + tpx + 1, x[i]) - stx;
    y[i] = lower_bound(sty + 1, sty + tpy + 1, y[i]) - sty;
    vec[x[i]].push_back(i);
  }
  --tpx;
  --tpy;
  for (int i = 1; i <= tpy + 5; i++) {
    sleny[i] = (sleny[i - 1] + (i - 2 >= 0 ? leny[i - 2] : 0)) % mod;
  }
  int ans = 0;
  for (int i = 1; i <= tpx; i++) {
    for (int j = 1; j <= k; j++) {
      pos[j].clear();
      pos[j].insert(0);
      pos[j].insert(tpy + 1);
    }
    for (int j = i; j <= tpx; j++)
      for (auto id : vec[j]) pos[c[id]].insert(y[id]);
    build();
    for (int j = 1; j <= k; j++) {
      auto it = pos[j].begin();
      while (1) {
        auto nxt = it;
        ++nxt;
        if (nxt == pos[j].end()) break;
        modify(*it + 1, *nxt - 1, *it + 1);
        it = nxt;
      }
    }
    for (int j = tpx; j >= i; j--) {
      ans = (ans + 1ll * lenx[i - 1] * lenx[j] % mod * sum[1]) % mod;
      for (auto id : vec[j]) {
        auto it = pos[c[id]].lower_bound(y[id]);
        auto pre = it, nxt = it;
        --pre;
        ++nxt;
        pos[c[id]].erase(it);
        modify(*pre + 1, *nxt - 1, *pre + 1);
      }
    }
  }
  cout << ans;
  return 0;
}