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>
constexpr int P = 1000000007, N = 2e3;
std::vector<int> vx, vy;
int sum[4 * N], tag[4 * N], mx[4 * N], mn[4 * N];
void pull(int p) {
  sum[p] = (sum[2 * p] + sum[2 * p + 1]) % P;
  mx[p] = std::max(mx[2 * p], mx[2 * p + 1]);
  mn[p] = std::min(mn[2 * p], mn[2 * p + 1]);
}
void modify(int p, int l, int r, int v) {
  tag[p] = mx[p] = mn[p] = v;
  sum[p] = 1ll * (vx.back() - vx[v]) * (vx[r] - vx[l]) % P;
}
void push(int p, int l, int r) {
  if (tag[p] == -1) return;
  int m = (l + r) / 2;
  modify(2 * p, l, m, tag[p]);
  modify(2 * p + 1, m, r, tag[p]);
  tag[p] = -1;
}
void build(int p, int l, int r, const std::vector<int> &a) {
  tag[p] = -1;
  if (r - l == 1) {
    mx[p] = mn[p] = a[l];
    sum[p] = 1ll * (vx.back() - vx[a[l]]) * (vx[r] - vx[l]) % P;
    return;
  }
  int m = (l + r) / 2;
  build(2 * p, l, m, a);
  build(2 * p + 1, m, r, a);
  pull(p);
}
void rangeModify(int p, int l, int r, int x, int y, int v) {
  if (l >= y || r <= x || mn[p] >= v) return;
  if (l >= x && r <= y && mx[p] <= v) return modify(p, l, r, v);
  push(p, l, r);
  int m = (l + r) / 2;
  rangeModify(2 * p, l, m, x, y, v);
  rangeModify(2 * p + 1, m, r, x, y, v);
  pull(p);
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, k, L;
  std::cin >> n >> k >> L;
  std::vector<int> x(n), y(n), c(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> x[i] >> y[i] >> c[i];
    --c[i];
  }
  std::vector<int> px(n);
  std::iota(px.begin(), px.end(), 0);
  std::sort(px.begin(), px.end(), [&](int i, int j) { return x[i] < x[j]; });
  std::vector<int> py(n);
  std::iota(py.begin(), py.end(), 0);
  std::sort(py.begin(), py.end(), [&](int i, int j) { return y[i] < y[j]; });
  vx = x;
  vy = y;
  vx.push_back(-1);
  vx.push_back(L);
  vy.push_back(-1);
  vy.push_back(L);
  std::sort(vx.begin(), vx.end());
  std::sort(vy.begin(), vy.end());
  for (int i = 0; i < n; ++i) x[px[i]] = y[py[i]] = i + 1;
  int ans = 0;
  for (int u = k; u <= n; ++u) {
    std::vector<int> r(n, n + 1), cnt(k);
    std::vector<std::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) 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]);
    int res = 0;
    for (int d = 0; d + 1 <= u; ++d) {
      res = (res + 1ll * (vy[d + 1] - vy[d]) * sum[1]) % P;
      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 : *std::prev(it);
      rangeModify(1, 0, n, l, x[j], r);
    }
    ans = (ans + 1ll * res * (vy[u + 1] - vy[u])) % P;
  }
  std::cout << ans << "\n";
  return 0;
}