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>
const int MAXN = 4000 + 5;
const int ha = 1e9 + 7;
int mn[MAXN << 2], cmn[MAXN << 2], coe[MAXN << 2], sm[MAXN << 2],
    cnt[MAXN << 2], mx[MAXN << 2];
int n, k, L;
inline void pushup(int x) {
  if (mn[((x) << 1)] < mn[((x) << 1 | 1)]) {
    mn[x] = mn[((x) << 1)];
    cnt[x] = cnt[((x) << 1)];
    coe[x] = coe[((x) << 1)];
    cmn[x] = std::min(mn[((x) << 1 | 1)], cmn[((x) << 1)]);
  } else if (mn[((x) << 1)] > mn[((x) << 1 | 1)]) {
    mn[x] = mn[((x) << 1 | 1)];
    cnt[x] = cnt[((x) << 1 | 1)];
    coe[x] = coe[((x) << 1 | 1)];
    cmn[x] = std::min(mn[((x) << 1)], cmn[((x) << 1 | 1)]);
  } else {
    mn[x] = mn[((x) << 1)];
    cnt[x] = cnt[((x) << 1)] + cnt[((x) << 1 | 1)];
    coe[x] = (coe[((x) << 1)] + coe[((x) << 1 | 1)]) % ha;
    cmn[x] = std::min(cmn[((x) << 1)], cmn[((x) << 1 | 1)]);
  }
  sm[x] = (sm[((x) << 1)] + sm[((x) << 1 | 1)]) % ha;
  mx[x] = std::max(mx[((x) << 1)], mx[((x) << 1 | 1)]);
}
std::vector<int> row, col;
inline void cover(int x, int d) {
  if (mn[x] < d) {
    if (mx[x] == mn[x]) mx[x] = d;
    (sm[x] += ha - 1ll * coe[x] % ha * mn[x] % ha) %= ha;
    mn[x] = d;
    (sm[x] += 1ll * coe[x] * mn[x] % ha) %= ha;
  }
}
int f[MAXN];
inline void pushdown(int x) {
  cover(((x) << 1), mn[x]);
  cover(((x) << 1 | 1), mn[x]);
}
inline void build(int x, int l, int r) {
  if (l == r) {
    mn[x] = mx[x] = f[l];
    cmn[x] = 1e9 + 1919810;
    cnt[x] = 1;
    coe[x] = col[l - 1] - (l == 1 ? -1 : col[l - 2]);
    sm[x] = 1ll * coe[x] * f[l] % ha;
    return;
  }
  int mid = (l + r) >> 1;
  build(((x) << 1), l, mid);
  build(((x) << 1 | 1), mid + 1, r);
  pushup(x);
}
inline void modify(int x, int l, int r, int L, int R, int d) {
  if (L > R) return;
  if (mn[x] >= d) return;
  if (l == L && r == R && cmn[x] > d) {
    cover(x, d);
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(x);
  if (R <= mid)
    modify(((x) << 1), l, mid, L, R, d);
  else if (L > mid)
    modify(((x) << 1 | 1), mid + 1, r, L, R, d);
  else
    modify(((x) << 1), l, mid, L, mid, d),
        modify(((x) << 1 | 1), mid + 1, r, mid + 1, R, d);
  pushup(x);
}
int x[MAXN], y[MAXN], c[MAXN];
int t[MAXN], cnt0;
std::vector<int> R[MAXN], C[MAXN];
std::set<std::pair<int, int> > G[MAXN];
inline void add(int o) {
  for (auto x : C[o]) {
    ++t[c[x]];
    cnt0 -= t[c[x]] == 1;
  }
}
inline void del(int o) {
  for (auto x : C[o]) {
    --t[c[x]];
    cnt0 += t[c[x]] == 0;
  }
}
inline int suf(int i) {
  auto it = G[c[i]].lower_bound(std::make_pair(y[i], i));
  ++it;
  if (it == G[c[i]].end()) return L;
  return y[it->second];
}
inline int pre(int x, int l, int r, int d) {
  if (mx[x] < d) return 1e9;
  if (l == r) return l;
  int mid = (l + r) >> 1;
  pushdown(x);
  int t = pre(((x) << 1), l, mid, d);
  if (t == 1e9) t = pre(((x) << 1 | 1), mid + 1, r, d);
  return t;
}
inline int pre(int i) {
  auto it = G[c[i]].lower_bound(std::make_pair(y[i], i));
  if (it == G[c[i]].begin()) return 0;
  --it;
  return it->first;
}
inline int query(int x, int l, int r, int p) {
  if (l == r) return mn[x];
  int mid = (l + r) >> 1;
  pushdown(x);
  if (p <= mid)
    return query(((x) << 1), l, mid, p);
  else
    return query(((x) << 1 | 1), mid + 1, r, p);
}
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);
    row.push_back(x[i]);
    col.push_back(y[i]);
  }
  std::sort(row.begin(), row.end());
  row.erase(std::unique(row.begin(), row.end()), row.end());
  std::sort(col.begin(), col.end());
  col.erase(std::unique(col.begin(), col.end()), col.end());
  for (int i = 1; i <= n; ++i) {
    x[i] = std::lower_bound(row.begin(), row.end(), x[i]) - row.begin() + 1;
    y[i] = std::lower_bound(col.begin(), col.end(), y[i]) - col.begin() + 1;
  }
  int N = row.size(), M = col.size(), ans = 0;
  for (int i = 1; i <= n; ++i) R[x[i]].push_back(i);
  for (int up = 1; up <= N; ++up) {
    int d1 = row[up - 1] - (up == 1 ? -1 : row[up - 2]);
    for (int i = 1; i <= M; ++i) f[i] = L, C[i].clear();
    for (int i = 1; i <= k; ++i) t[i] = 0, G[i].clear();
    cnt0 = k;
    for (int i = 1; i <= n; ++i)
      if (x[i] >= up)
        C[y[i]].push_back(i), G[c[i]].insert(std::make_pair(y[i], i));
    int p = 0;
    for (int i = 1; i <= M; ++i) {
      while (p <= M && cnt0) ++p, add(p);
      f[i] = p <= M ? col[p - 1] : L;
      del(i);
    }
    build(1, 1, M);
    for (int down = N; down >= up; --down) {
      int d2 = (down == N ? L : row[down]) - row[down - 1];
      int gx = ha - sm[1];
      (gx += 1ll * (col[M - 1] + 1) * L % ha) %= ha;
      (ans += 1ll * d1 * d2 % ha * gx % ha) %= ha;
      for (auto x : R[down]) {
        int p = std::max(pre(1, 1, M, col[y[x] - 1]), pre(x) + 1);
        int v = suf(x);
        if (v != L) v = col[v - 1];
        modify(1, 1, M, p, y[x], v);
        G[c[x]].erase(std::make_pair(y[x], x));
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}