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 MN = 4005, mod = 1e9 + 7;
int N, K, L, ta, tb;
int pa[MN], pb[MN], a[MN], b[MN], c[MN];
long long sum[MN << 1], tg[MN << 1], mn[MN << 1], mx[MN << 1];
vector<pair<int, int> > v[MN];
multiset<int> st[MN];
inline void inc(int &x, int y) { x = (x + y) % mod; }
inline void update(int now) {
  mn[now] = min(mn[now << 1], mn[now << 1 | 1]);
  mx[now] = max(mx[now << 1], mx[now << 1 | 1]);
  sum[now] = (sum[now << 1] + sum[now << 1 | 1]) % mod;
}
inline void build(int now, int l, int r) {
  tg[now] = 0;
  if (l == r) {
    mx[now] = mn[now] = sum[now] = 0;
    return;
  }
  int mid = l + r >> 1;
  build(now << 1, l, mid), build(now << 1 | 1, mid + 1, r);
  update(now);
}
inline void pushtag(int now, int l, int r, int c) {
  if (mn[now] >= c) return;
  tg[now] = c, sum[now] = 1ll * (L - pa[c]) * (pa[r] - pa[l - 1]) % mod;
  mn[now] = mx[now] = c;
  return;
}
inline void pushdown(int now, int l, int r) {
  if (tg[now]) {
    int mid = l + r >> 1;
    pushtag(now << 1, l, mid, tg[now]),
        pushtag(now << 1 | 1, mid + 1, r, tg[now]);
    tg[now] = 0;
  }
}
inline void change(int now, int l, int r, int ql, int qr, long long c) {
  if (ql > qr) return;
  if (l == ql && r == qr && (mn[now] >= c || mx[now] <= c)) {
    pushtag(now, l, r, c);
    return;
  }
  pushdown(now, l, r);
  int mid = l + r >> 1;
  if (mid >= qr)
    change(now << 1, l, mid, ql, qr, c);
  else if (mid + 1 <= ql)
    change(now << 1 | 1, mid + 1, r, ql, qr, c);
  else
    change(now << 1, l, mid, ql, mid, c),
        change(now << 1 | 1, mid + 1, r, mid + 1, qr, c);
  update(now);
}
int main() {
  scanf("%d%d%d", &N, &K, &L);
  for (int i = 1; i <= N; ++i) scanf("%d%d%d", &a[i], &b[i], &c[i]);
  for (int i = 1; i <= N; ++i) pa[i] = a[i], pb[i] = b[i];
  ta = N, pa[++ta] = L;
  tb = N, pb[++tb] = L;
  sort(pa + 1, pa + 1 + ta);
  sort(pb + 1, pb + 1 + tb);
  ta = unique(pa + 1, pa + 1 + ta) - pa - 1;
  tb = unique(pb + 1, pb + 1 + tb) - pb - 1;
  pa[0] = pb[0] = -1;
  for (int i = 1; i <= N; ++i) {
    a[i] = lower_bound(pa + 1, pa + 1 + ta, a[i]) - pa;
    b[i] = lower_bound(pb + 1, pb + 1 + tb, b[i]) - pb;
  }
  for (int i = 1; i <= N; ++i) v[b[i]].emplace_back(make_pair(a[i], c[i]));
  int res = 0;
  for (int i = 1; i <= tb; ++i) {
    build(1, 1, ta + 1);
    for (int j = 1; j <= K; ++j) st[j].clear();
    for (int j = i; j <= tb; ++j)
      for (auto o : v[j]) st[o.second].insert(o.first);
    for (int j = 1; j <= K; ++j) {
      st[j].insert(ta);
      int lst = 0;
      for (int o : st[j]) {
        change(1, 1, ta, lst + 1, o, o);
        lst = o;
      }
      st[j].insert(0);
    }
    for (int j = tb; j >= i; --j) {
      for (auto o : v[j]) {
        auto it1 = st[o.second].lower_bound(o.first), it2 = it1, it3 = it1;
        --it2, ++it3;
        change(1, 1, ta, *it2 + 1, o.first, *it3);
        st[o.second].erase(it1);
      }
      inc(res,
          1ll * sum[1] * (pb[j] - pb[j - 1]) % mod * (pb[i] - pb[i - 1]) % mod);
    }
  }
  printf("%d\n", res);
  return 0;
}