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;
int n, m, L, lst[3005], col[3005], val[3005], tot, vis[3005];
struct Node {
  int x, y, c, i;
} A[3005];
bool cmpx(Node a, Node b) { return a.x < b.x; }
bool cmpy(Node a, Node b) { return a.y < b.y; }
struct Q {
  int l[3005], r[3005];
  void Delete(int x) {
    l[r[x]] = l[x];
    r[l[x]] = r[x];
  }
} q, w;
struct Data {
  int mn, mx, s, tag;
  Data(int a = 0, int b = 0, int c = 0, int d = 0) {
    mn = a, mx = b, s = c, tag = d;
  }
  Data operator+(Data b) const {
    return Data(min(mn, b.mn), max(mx, b.mx), (s + b.s) % 1000000007, 0);
  }
} S[3005 * 2];
int f[3005];
void Update(int x, int l, int r, long long t) {
  S[x] = Data(t, t, 1LL * (val[r] - val[l - 1]) * t % 1000000007, t);
}
void Build(int x, int l, int r) {
  if (l == r) {
    Update(x, l, r, f[l]);
    return;
  }
  int mid = (l + r) / 2;
  Build((x << 1), l, mid);
  Build((x << 1 | 1), mid + 1, r);
  S[x] = S[(x << 1)] + S[(x << 1 | 1)];
}
void Modify(int x, int l, int r, int L, long long t) {
  if (S[x].mn >= t) return;
  if (S[x].mx <= t && l == L) {
    Update(x, l, r, t);
    return;
  }
  int mid = (l + r) / 2;
  if (S[x].tag) {
    Update((x << 1), l, mid, S[x].tag);
    Update((x << 1 | 1), mid + 1, r, S[x].tag);
    S[x].tag = 0;
  }
  if (L <= mid) Modify((x << 1), l, mid, L, t);
  Modify((x << 1 | 1), mid + 1, r, max(mid + 1, L), t);
  S[x] = S[(x << 1)] + S[(x << 1 | 1)];
}
int main() {
  scanf("%d%d%d", &n, &m, &L);
  for (int i = 1; i <= n; i++) scanf("%d%d%d", &A[i].x, &A[i].y, &A[i].c);
  sort(A + 1, A + n + 1, cmpy);
  A[0].x = A[0].y = -1;
  A[n + 1].x = A[n + 1].y = L;
  for (int i = 0; i <= n + 1; i++) val[i] = A[i].y, A[i].i = i;
  for (int i = 1; i <= n; i++) {
    int l = w.l[i] = lst[A[i].c];
    lst[A[i].c] = i;
    w.r[i] = n + 1;
    w.r[l] = i;
  }
  sort(A + 1, A + n + 1, cmpx);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (A[i].x ^ A[i - 1].x) {
      for (int j = 1; j < i; j++) col[A[j].i] = 0;
      for (int j = i; j <= n; j++) col[A[j].i] = A[j].c;
      for (int l = 1, r = 1; l <= n; l++) {
        for (; r <= n && tot < m; r++)
          if (col[r] && !vis[col[r]]++) tot++;
        f[l] = (tot < m) ? L : val[r - 1];
        if (col[l] && !--vis[col[l]]) tot--;
      }
      q = w;
      Build(1, 1, n);
      for (int j = n; j >= i; j--) {
        ans += (1LL * (val[n] + 1) * L - S[1].s) % 1000000007 *
               (A[i].x - A[i - 1].x) % 1000000007 * (A[j + 1].x - A[j].x) %
               1000000007;
        int id = A[j].i, l = q.l[id], r = q.r[id];
        Modify(1, 1, n, l + 1, val[r]);
        q.Delete(id);
      }
      ans %= 1000000007;
    }
    w.Delete(A[i].i);
  }
  printf("%lld\n", ans);
}