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 P = 1e9 + 7, INF = 0x3f3f3f3f;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long first) {
  return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;
}
inline int rd() {
  int first = 0;
  char p = getchar();
  while (p < '0' || p > '9') p = getchar();
  while (p >= '0' && p <= '9') first = first * 10 + p - '0', p = getchar();
  return first;
}
const int N = 2e3 + 10;
int n, k, L, nxt[N], cnt[N], pos[N];
set<int> s[N];
struct _ {
  int first, second, c, id;
} a[N], b[N];
bool cmpx(_ a, _ b) { return a.first < b.first; }
bool cmpy(_ a, _ b) { return a.second < b.second; }
struct {
  int sum[N << 2], mi[N << 2], ma[N << 2], tag[N << 2];
  void upd(int o, int l, int r, int v) {
    tag[o] = mi[o] = ma[o] = v;
    sum[o] = (long long)(L - b[v].second) * (b[r].second - b[l - 1].second) % P;
  }
  void pu(int o) {
    sum[o] = (sum[(o << 1)] + sum[((o << 1) | 1)]) % P;
    mi[o] = min(mi[(o << 1)], mi[((o << 1) | 1)]);
    ma[o] = max(ma[(o << 1)], ma[((o << 1) | 1)]);
  }
  void pd(int o, int l, int r) {
    if (tag[o] != -1) {
      upd((o << 1), l, ((l + r) >> 1), tag[o]);
      upd(((o << 1) | 1), ((l + r) >> 1) + 1, r, tag[o]);
      tag[o] = -1;
    }
  }
  void build(int o, int l, int r) {
    tag[o] = -1;
    if (l == r) return upd(o, l, l, nxt[l]);
    build((o << 1), l, ((l + r) >> 1)),
        build(((o << 1) | 1), ((l + r) >> 1) + 1, r);
    pu(o);
  }
  void update(int o, int l, int r, int ql, int qr, int v) {
    if (mi[o] >= v) return;
    if (ql <= l && r <= qr && ma[o] <= v) return upd(o, l, r, v);
    pd(o, l, r);
    if (((l + r) >> 1) >= ql) update((o << 1), l, ((l + r) >> 1), ql, qr, v);
    if (((l + r) >> 1) < qr)
      update(((o << 1) | 1), ((l + r) >> 1) + 1, r, ql, qr, v);
    pu(o);
  }
} sgt;
int main() {
  scanf("%d%d%d", &n, &k, &L);
  for (int i = 1; i <= n; ++i)
    scanf("%d%d%d", &a[i].first, &a[i].second, &a[i].c);
  sort(a + 1, a + 1 + n, cmpx);
  a[0].first = -1, a[n + 1].first = L;
  int ans = 0;
  for (int i = k; i <= n; ++i) {
    int len = a[i + 1].first - a[i].first;
    if (!len) continue;
    for (int j = 1; j <= i; ++j) {
      b[j] = a[j];
      b[j].id = j;
    }
    sort(b + 1, b + 1 + i, cmpy);
    for (int j = 1; j <= i; ++j) {
      nxt[j] = i + 1;
      pos[b[j].id] = j;
      s[b[j].c].insert(j);
    }
    for (int j = 1, now = 1, cur = 0; j <= i; ++j) {
      while (now <= i && cur < k) {
        if (!cnt[b[now++].c]++) ++cur;
      }
      if (cur == k) nxt[j] = now - 1;
      if (!--cnt[b[j].c]) --cur;
    }
    b[0].second = -1, b[i + 1].second = L;
    sgt.build(1, 1, i);
    int res = 0;
    for (int j = 1; j <= i; ++j) {
      int len2 = a[j].first - a[j - 1].first;
      res = (res + (long long)len2 * sgt.sum[1]) % P;
      auto p = s[a[j].c].lower_bound(pos[j]);
      int l = p == s[a[j].c].begin() ? 0 : *prev(p);
      int r = next(p) == s[a[j].c].end() ? i + 1 : *next(p);
      s[a[j].c].erase(p);
      sgt.update(1, 1, i, l + 1, pos[j], r);
    }
    ans = (ans + (long long)res * len) % P;
  }
  printf("%d\n", ans);
}