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>
int n, k, L, x[2001], y[2001], c[2001], origx[2010], origy[2010], limx, limy;
std::vector<std::pair<int, int> > vec[2001];
std::multiset<int> set[2001];
int mn[100001], sum[100001], ans[100001], lazy[100001];
const int P = 1000000007;
inline int mul(const int &a, const int &b) { return 1ll * a * b % P; }
inline int sub(int a, const int &b) {
  a -= b;
  return (a < 0) ? a + P : a;
}
inline int add(int a, const int &b) {
  a += b;
  return (a >= P) ? a - P : a;
}
void pushup(int root) {
  sum[root] = add(sum[root << 1], sum[root << 1 | 1]);
  ans[root] = add(ans[root << 1], ans[root << 1 | 1]);
  mn[root] = std::min(mn[root << 1], mn[root << 1 | 1]);
}
void build(int root, int l, int r) {
  lazy[root] = -1;
  if (l == r) {
    sum[root] = origy[l] - origy[l - 1];
    ans[root] = mul(L - origy[l], sum[root]);
    mn[root] = l;
    return;
  }
  build(root << 1, l, (l + r) >> 1);
  build(root << 1 | 1, ((l + r) >> 1) + 1, r);
  pushup(root);
}
void pushdown(int x, int y) {
  lazy[x] = y;
  mn[x] = y;
  ans[x] = mul(sum[x], L - origy[y]);
}
void spread(int x) {
  if (~lazy[x]) {
    pushdown(x << 1, lazy[x]);
    pushdown(x << 1 | 1, lazy[x]);
    lazy[x] = -1;
  }
}
int find(int root, int l, int r, int x) {
  spread(root);
  if (l == r && mn[root] < x) return l;
  if (l == r && mn[root] >= x) return -1;
  if (mn[root << 1 | 1] < x)
    return find(root << 1 | 1, ((l + r) >> 1) + 1, r, x);
  else
    return find(root << 1, l, (l + r) >> 1, x);
}
void upd(int root, int l, int r, int el, int er, int x) {
  if (el > r || er < l) return;
  if (el <= l && er >= r) {
    pushdown(root, x);
    return;
  }
  spread(root);
  upd(root << 1, l, (l + r) >> 1, el, er, x);
  upd(root << 1 | 1, ((l + r) >> 1) + 1, r, el, er, x);
  pushup(root);
}
void del(int l, int r) {
  int x = find(1, 1, limy, r);
  if (x < l) return;
  upd(1, 1, limy, l, x, r);
}
int main() {
  scanf("%d%d%d", &n, &k, &L);
  for (int i = 1; i <= n; i++)
    scanf("%d%d%d", x + i, y + i, c + i), origx[i] = x[i], origy[i] = y[i];
  std::sort(origx + 1, origx + n + 1);
  limx = std::unique(origx + 1, origx + n + 1) - origx - 1;
  for (int i = 1; i <= n; i++)
    x[i] = std::lower_bound(origx + 1, origx + limx + 1, x[i]) - origx;
  std::sort(origy + 1, origy + n + 1);
  limy = std::unique(origy + 1, origy + n + 1) - origy - 1;
  for (int i = 1; i <= n; i++)
    y[i] = std::lower_bound(origy + 1, origy + limy + 1, y[i]) - origy;
  origx[limx + 1] = origy[limy + 1] = L;
  origx[0] = origy[0] = -1;
  for (int i = 1; i <= n; i++) vec[x[i]].push_back(std::make_pair(y[i], c[i]));
  int ans = 0;
  for (int i = limx; i; i--) {
    for (int j = 1; j <= k; j++)
      set[j].clear(), set[j].insert(limy + 1), set[j].insert(0);
    for (int j = i; j <= limx; j++)
      for (int k = 0; k < vec[j].size(); k++)
        set[vec[j][k].second].insert(vec[j][k].first);
    build(1, 1, limy);
    for (int j = 1; j <= k; j++)
      for (std::multiset<int>::iterator it = set[j].begin(); it != set[j].end();
           ++it) {
        if (*it == limy + 1) break;
        auto now = it;
        ++now;
        if (*it < *now) del(*it + 1, *now);
      }
    for (int j = limx; j >= i; j--) {
      ans = add(ans, mul(mul(origx[i] - origx[i - 1], origx[j + 1] - origx[j]),
                         ::ans[1]));
      for (int k = 0; k < vec[j].size(); k++) {
        int y = vec[j][k].first, c = vec[j][k].second;
        auto now = set[c].find(y);
        int l, r;
        auto tem = now;
        l = *--tem + 1;
        tem = now;
        r = *++tem;
        del(l, r);
        set[c].erase(now);
      }
    }
  }
  printf("%d\n", ans);
}