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 N = 2000 + 10, MOD = 1e9 + 7;
int n, m, L;
struct Point {
  int x, y, c;
} p[N];
int numx[N], totx, numy[N], toty;
vector<int> vx[N], vy[N];
struct List {
  int l[N], r[N];
  void del(int x) {
    l[r[x]] = l[x];
    r[l[x]] = r[x];
  }
} q, nq;
int last[N];
bool vis[N];
int f[N], cnt[N];
long long mn[N << 2], mx[N << 2], sum[N << 2], tag[N << 2], ans;
bool cmp(Point a, Point b) { return a.y == b.y ? a.x < b.x : a.y < b.y; }
void update(int x) {
  sum[x] = (sum[x << 1] + sum[x << 1 | 1]) % MOD;
  mn[x] = mn[x << 1];
  mx[x] = mx[x << 1 | 1];
}
void upd(int x, int l, int r, int C) {
  sum[x] = 1ll * (numy[r] - numy[l - 1]) * (L - numy[C]) % MOD;
  mn[x] = mx[x] = tag[x] = C;
}
void build(int x, int l, int r) {
  if (l == r) {
    upd(x, l, r, f[l]);
    return;
  }
  int mid = (l + r) >> 1;
  build(x << 1, l, mid);
  build(x << 1 | 1, mid + 1, r);
  update(x);
}
void pushdown(int x, int l, int r) {
  if (!tag[x]) return;
  int mid = (l + r) >> 1;
  upd(x << 1, l, mid, tag[x]);
  upd(x << 1 | 1, mid + 1, r, tag[x]);
  tag[x] = 0;
}
void modify(int x, int l, int r, int L, int C) {
  if (r < L || mn[x] >= C) return;
  if (l == L && mx[x] <= C) {
    upd(x, l, r, C);
    return;
  }
  pushdown(x, l, r);
  int mid = (l + r) >> 1;
  if (L <= mid) modify(x << 1, l, mid, L, C);
  modify(x << 1 | 1, mid + 1, r, max(L, mid + 1), C);
  update(x);
}
int main() {
  scanf("%d%d%d", &n, &m, &L);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d%d", &p[i].y, &p[i].x, &p[i].c);
    numx[++totx] = p[i].x;
    numy[++toty] = p[i].y;
  }
  sort(numx + 1, numx + totx + 1);
  sort(numy + 1, numy + toty + 1);
  totx = unique(numx + 1, numx + totx + 1) - numx - 1;
  toty = unique(numy + 1, numy + toty + 1) - numy - 1;
  numx[totx + 1] = numy[toty + 1] = L;
  numx[0] = numy[0] = -1;
  sort(p + 1, p + n + 1, cmp);
  p[0].y = 0;
  p[n + 1].y = toty + 1;
  for (int i = 1; i <= n; ++i) {
    p[i].x = lower_bound(numx + 1, numx + totx + 1, p[i].x) - numx;
    p[i].y = lower_bound(numy + 1, numy + toty + 1, p[i].y) - numy;
    vx[p[i].x].push_back(i);
    vy[p[i].y].push_back(i);
    q.l[i] = last[p[i].c];
    q.r[i] = n + 1;
    q.r[last[p[i].c]] = i;
    last[p[i].c] = i;
  }
  for (int i = 1; i <= totx; ++i) {
    memset(cnt, 0, sizeof(cnt));
    int tot = 0;
    for (int l = 1, r = 1; l <= toty; ++l) {
      for (; r <= toty && tot < m; ++r) {
        for (int j = 0; j < vy[r].size(); ++j) {
          int t = vy[r][j];
          if (vis[t]) continue;
          if (!cnt[p[t].c]) tot++;
          cnt[p[t].c]++;
        }
      }
      if (tot == m)
        f[l] = r - 1;
      else
        f[l] = toty + 1;
      for (int j = 0; j < vy[l].size(); ++j) {
        int t = vy[l][j];
        if (vis[t]) continue;
        cnt[p[t].c]--;
        if (!cnt[p[t].c]) tot--;
      }
    }
    memset(tag, 0, sizeof(tag));
    build(1, 1, toty);
    nq = q;
    for (int j = totx; j >= i; --j) {
      long long add = 1ll * sum[1] * (numx[j + 1] - numx[j]) % MOD *
                      (numx[i] - numx[i - 1]) % MOD;
      ans = (ans + add) % MOD;
      for (int k = 0; k < vx[j].size(); ++k) {
        int t = vx[j][k];
        modify(1, 1, toty, p[nq.l[t]].y + 1, p[nq.r[t]].y);
        nq.del(t);
      }
    }
    for (int j = 0; j < vx[i].size(); ++j) vis[vx[i][j]] = 1, q.del(vx[i][j]);
  }
  printf("%lld", ans);
  return 0;
}