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 = 2003;
const int mod = 1e9 + 7;
int tag[N << 2], mn[N << 2], mx[N << 2], sum[N << 2];
vector<int> vx, vy;
void solve(int pos, int l, int r, int v) {
  tag[pos] = mx[pos] = mn[pos] = v;
  sum[pos] = 1ll * (vx.back() - vx[v]) * (vx[r] - vx[l]) % mod;
}
void pushup(int pos) {
  sum[pos] = (sum[pos << 1] + sum[pos << 1 | 1]) % mod;
  mn[pos] = min(mn[pos << 1], mn[pos << 1 | 1]);
  mx[pos] = max(mx[pos << 1], mx[pos << 1 | 1]);
}
void pushdown(int pos, int l, int r) {
  if (tag[pos] == -1) return;
  int m = l + r >> 1;
  solve(pos << 1, l, m, tag[pos]);
  solve(pos << 1 | 1, m, r, tag[pos]);
  tag[pos] = -1;
}
void build(int pos, int l, int r, const vector<int>& a) {
  tag[pos] = -1;
  if (l + 1 == r) {
    mn[pos] = mx[pos] = a[l];
    sum[pos] = 1ll * (vx.back() - vx[a[l]]) * (vx[r] - vx[l]) % mod;
    return;
  }
  int m = l + r >> 1;
  build(pos << 1, l, m, a);
  build(pos << 1 | 1, m, r, a);
  pushup(pos);
}
void upd(int pos, int l, int r, int x, int y, int v) {
  if (l >= y || r <= x || mn[pos] >= v) return;
  if (l >= x && r <= y && mx[pos] <= v) {
    solve(pos, l, r, v);
    return;
  }
  pushdown(pos, l, r);
  int m = l + r >> 1;
  upd(pos << 1, l, m, x, y, v);
  upd(pos << 1 | 1, m, r, x, y, v);
  pushup(pos);
}
int main() {
  int n, k, L;
  scanf("%d%d%d", &n, &k, &L);
  vector<int> x(n), y(n), c(n);
  for (int i = (0); i < (n); i++) {
    scanf("%d%d%d", &x[i], &y[i], &c[i]);
    --c[i];
  }
  vx = x, vy = y;
  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());
  vector<int> px(n), py(n);
  iota(px.begin(), px.end(), 0);
  iota(py.begin(), py.end(), 0);
  sort(px.begin(), px.end(), [&](int i, int j) { return x[i] < x[j]; });
  sort(py.begin(), py.end(), [&](int i, int j) { return y[i] < y[j]; });
  for (int i = (0); i < (n); i++) x[px[i]] = y[py[i]] = i + 1;
  long long ans = 0;
  for (int u = k; u <= n; ++u) {
    vector<int> r(n, n + 1), cnt(k);
    vector<set<int>> s(n);
    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) r[l] = i;
      int j = px[l];
      if (y[j] <= u && !--cnt[c[j]]) --cur;
    }
    build(1, 0, n, r);
    for (int i = (0); i < (n); i++) {
      if (y[i] <= u) s[c[i]].insert(x[i]);
    }
    long long res = 0;
    for (int d = 0; d < u; ++d) {
      res = (res + 1ll * (vy[d + 1] - vy[d]) * sum[1]) % mod;
      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);
      upd(1, 0, n, l, x[j], r);
    }
    ans = (ans + 1ll * res * (vy[u + 1] - vy[u])) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}