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 = 2e3 + 10;
const int MOD = 1e9 + 7;
void add(int &x, int y) {
  x += y;
  x -= (x >= MOD) * MOD;
}
struct obj {
  int x, y, c;
};
struct segTree {
  int d[N * 4], cnt[N * 4], sum[N * 4], lazy[N * 4];
  void build(int id, int l, int r, const int x[], const int v[]) {
    lazy[id] = -1;
    if (l == r) {
      d[id] = v[l];
      cnt[id] = x[l + 1] - x[l];
      sum[id] = (long long)d[id] * cnt[id] % MOD;
      return;
    }
    int mid = (l + r) >> 1;
    build(id << 1, l, mid, x, v);
    build(id << 1 | 1, mid + 1, r, x, v);
    d[id] = max(d[id << 1], d[id << 1 | 1]);
    cnt[id] = (cnt[id << 1] + cnt[id << 1 | 1]) % MOD;
    sum[id] = (sum[id << 1] + sum[id << 1 | 1]) % MOD;
  }
  void doLazy(int id, int l, int r) {
    if (lazy[id] == -1) return;
    d[id] = lazy[id];
    sum[id] = (long long)d[id] * cnt[id] % MOD;
    if (l < r) {
      lazy[id << 1] = lazy[id];
      lazy[id << 1 | 1] = lazy[id];
    }
    lazy[id] = -1;
  }
  void update(int id, int l, int r, int u, int v, int val) {
    doLazy(id, l, r);
    if (v < l || r < u) return;
    if (u <= l && r <= v) {
      lazy[id] = val;
      doLazy(id, l, r);
      return;
    }
    int mid = (l + r) >> 1;
    update(id << 1, l, mid, u, v, val);
    update(id << 1 | 1, mid + 1, r, u, v, val);
    d[id] = max(d[id << 1], d[id << 1 | 1]);
    cnt[id] = (cnt[id << 1] + cnt[id << 1 | 1]) % MOD;
    sum[id] = (sum[id << 1] + sum[id << 1 | 1]) % MOD;
  }
  int findPos(int id, int l, int r, int val) {
    doLazy(id, l, r);
    if (d[id] <= val) return N;
    if (l == r) return l;
    int mid = (l + r) >> 1;
    int res = findPos(id << 1, l, mid, val);
    if (res != N) return res;
    return findPos(id << 1 | 1, mid + 1, r, val);
  }
  int getSum() { return sum[1]; }
} ST;
int n, k, l;
obj a[N];
int nX, nY, x[N], y[N];
int pre[N], nxt[N], ini[N], cnt[N];
obj b[N];
set<int> col[N];
int calc(int v) {
  int m = 0;
  while (a[m + 1].y <= v && m < n) m++;
  for (int i = 1; i <= m; i++) b[i] = a[i];
  sort(b + 1, b + 1 + m, [](const obj &a, const obj &b) { return a.x < b.x; });
  for (int i = 1; i <= k; i++) cnt[i] = 0;
  int ptrL = 1, ptrR = 1, curCol = 0;
  for (int r = 1; r < nX; r++) {
    while (ptrR <= m && b[ptrR].x <= r) {
      if (cnt[b[ptrR].c]++ == 0) curCol++;
      ptrR++;
    }
    while (ptrL <= m && cnt[b[ptrL].c] > 1) {
      cnt[b[ptrL].c]--;
      ptrL++;
    }
    if (curCol == k)
      ini[r] = x[b[ptrL].x];
    else
      ini[r] = x[1];
  }
  for (int i = 1; i <= k; i++) {
    col[i].clear();
    col[i].insert(1);
    col[i].insert(nX);
  }
  for (int i = m; i > 0; i--) {
    auto it = col[a[i].c].lower_bound(a[i].x);
    nxt[i] = *it;
    if (nxt[i] != a[i].x) --it;
    pre[i] = *it;
    col[a[i].c].insert(a[i].x);
  }
  ST.build(1, 1, nX - 1, x, ini);
  int res = 0, curY = 0;
  for (int i = 1; i <= m; i++) {
    add(res, (long long)ST.getSum() * (y[a[i].y] - curY) % MOD);
    curY = y[a[i].y];
    int val = x[pre[i]];
    int pos = max(a[i].x, ST.findPos(1, 1, nX - 1, val));
    if (pos < nxt[i]) ST.update(1, 1, nX - 1, pos, nxt[i] - 1, val);
  }
  res = (long long)res * (y[v + 1] - y[v]) % MOD;
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k >> l;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].x >> a[i].y >> a[i].c;
    a[i].x++;
    a[i].y++;
    x[++nX] = a[i].x;
    y[++nY] = a[i].y;
  }
  x[++nX] = 0;
  x[++nX] = l + 1;
  y[++nY] = 0;
  y[++nY] = l + 1;
  sort(x + 1, x + 1 + nX);
  sort(y + 1, y + 1 + nY);
  nX = unique(x + 1, x + 1 + nX) - (x + 1);
  nY = unique(y + 1, y + 1 + nY) - (y + 1);
  for (int i = 1; i <= n; i++) {
    a[i].x = lower_bound(x + 1, x + 1 + nX, a[i].x) - x;
    a[i].y = lower_bound(y + 1, y + 1 + nY, a[i].y) - y;
  }
  sort(a + 1, a + 1 + n, [](const obj &a, const obj &b) { return a.y < b.y; });
  int ans = 0;
  for (int y = 2; y < nY; y++) add(ans, calc(y));
  cout << ans;
  return 0;
}