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 maxn = 2010, mod = 1e9 + 7, inf = 1e9 + 10;
pair<int, int> p[maxn];
int col[maxn];
int arrX[maxn], arrY[maxn], Cx, Cy;
vector<int> tdo[maxn];
multiset<int> color[maxn];
vector<int> inside[maxn];
struct Segment {
  int a[maxn], mn[4 * maxn], mx[4 * maxn], sm[4 * maxn], lz[4 * maxn];
  void merge(int id) {
    mn[id] = min(mn[2 * id], mn[2 * id + 1]);
    mx[id] = max(mx[2 * id], mx[2 * id + 1]);
    sm[id] = (sm[2 * id] + sm[2 * id + 1]) % mod;
  }
  void build(int l = 0, int r = Cy, int id = 1) {
    lz[id] = -1;
    if (r - l == 1) {
      mn[id] = mx[id] = a[l];
      sm[id] = 1ll * (arrY[r] - arrY[l]) * a[l] % mod;
      return;
    }
    int mid = (l + r) >> 1;
    build(l, mid, 2 * id);
    build(mid, r, 2 * id + 1);
    merge(id);
  }
  void shift(int l, int r, int id) {
    if (lz[id] == -1) return;
    mn[id] = mx[id] = lz[id];
    sm[id] = 1ll * lz[id] * (arrY[r] - arrY[l]) % mod;
    if (r - l > 1) lz[2 * id] = lz[2 * id + 1] = lz[id];
    lz[id] = -1;
  }
  void minimize(int f, int s, int x, int l = 0, int r = Cy, int id = 1) {
    shift(l, r, id);
    if (f >= s || l >= r || s <= l || r <= f || mx[id] < x) return;
    if (f <= l && r <= s && mn[id] >= x) {
      lz[id] = x;
      shift(l, r, id);
      return;
    }
    int mid = (l + r) >> 1;
    minimize(f, s, x, l, mid, 2 * id);
    minimize(f, s, x, mid, r, 2 * id + 1);
    merge(id);
  }
};
Segment seg;
void add(int id) {
  color[col[id]].insert(p[id].second);
  inside[p[id].second].push_back(col[id]);
}
void era(int id) {
  int c = col[id];
  auto it = color[c].find(p[id].second);
  if (color[c].count(p[id].second) > 1) {
    color[c].erase(it);
    return;
  }
  seg.minimize(*it, next(it) == color[c].end() ? Cy : *next(it),
               it == color[c].begin() ? 0 : (arrY[*prev(it)] + 1));
  color[c].erase(it);
}
long long solve() { return seg.sm[1]; }
int cnt[maxn];
int k;
void make() {
  memset(cnt, 0, sizeof cnt);
  int l = 0;
  int zrs = k;
  for (int r = 0; r < Cy; r++) {
    for (int c : inside[r]) {
      if (++cnt[c] == 1) zrs--;
    }
    while (zrs == 0) {
      for (int c : inside[l])
        if (--cnt[c] == 0) zrs++;
      l++;
    }
    seg.a[r] = (l == 0 ? 0 : arrY[l - 1] + 1);
  }
  for (int i = 0; i < Cy; i++) {
    inside[i].clear();
  }
  seg.build();
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(), cout.tie();
  int n, L;
  cin >> n >> k >> L;
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second >> col[i];
    arrX[Cx++] = p[i].first;
    arrY[Cy++] = p[i].second;
    col[i]--;
  }
  sort(arrX, arrX + Cx);
  Cx = unique(arrX, arrX + Cx) - arrX;
  sort(arrY, arrY + Cy);
  Cy = unique(arrY, arrY + Cy) - arrY;
  arrX[Cx] = arrY[Cy] = L;
  for (int i = 0; i < n; i++) {
    p[i].first = lower_bound(arrX, arrX + Cx, p[i].first) - arrX;
    p[i].second = lower_bound(arrY, arrY + Cy, p[i].second) - arrY;
    tdo[p[i].first].push_back(i);
  }
  int ans = 0;
  for (int l = 0; l < Cx; l++) {
    for (int r = l; r < Cx; r++) {
      for (int id : tdo[r]) add(id);
    }
    make();
    for (int r = Cx - 1; r >= l; r--) {
      int A = (r + 1 == Cx ? L : arrX[r + 1]) - arrX[r],
          B = arrX[l] - (l == 0 ? -1 : arrX[l - 1]);
      ans = (1ll * ans + 1ll * A * B % mod * solve()) % mod;
      for (int id : tdo[r]) era(id);
    }
  }
  if (ans < 0) ans += mod;
  return cout << ans << endl, 0;
}