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 mxn = 1 << 11;
const int mod = 1e9 + 7;
int n, k, l;
int x[mxn], y[mxn], c[mxn];
int yid[mxn], xid[mxn], xre[mxn];
int lst[mxn], p[mxn], py[mxn], pre[mxn], nex[mxn];
bool compx(int a, int b) { return x[a] < x[b]; }
bool compy(int a, int b) { return y[a] < y[b]; }
struct SEG {
  int val[mxn << 1], sum[mxn << 1], coef[mxn << 1], tag[mxn << 1];
  void push(int x, int v) {
    tag[x] = val[x] = v;
    sum[x] = 1LL * v * coef[x] % mod;
  }
  void pushdown(int x) {
    if (tag[x] != -1) {
      push(x << 1, tag[x]);
      push(x << 1 | 1, tag[x]);
      tag[x] = -1;
    }
  }
  void pushup(int x) {
    val[x] = val[x << 1 | 1];
    sum[x] = (sum[x << 1] + sum[x << 1 | 1]) % mod;
  }
  void build(int *p, int *c, int n, int i = 1, int a = 0, int b = mxn) {
    tag[i] = -1;
    if (a + 1 == b) {
      if (a < n) {
        val[i] = p[a];
        coef[i] = c[a];
      } else {
        val[i] = 1e9;
        coef[i] = 0;
      }
      sum[i] = 1LL * val[i] * coef[i] % mod;
      return;
    }
    int m = (a + b) >> 1;
    build(p, c, n, i << 1, a, m);
    build(p, c, n, i << 1 | 1, m, b);
    pushup(i);
    coef[i] = coef[i << 1] + coef[i << 1 | 1];
  }
  void upd(int l, int r, int v, int i = 1, int a = 0, int b = mxn) {
    if (l <= a && b <= r) return push(i, v);
    pushdown(i);
    int m = (a + b) >> 1;
    if (l < m) upd(l, r, v, i << 1, a, m);
    if (r > m) upd(l, r, v, i << 1 | 1, m, b);
    pushup(i);
  }
  int find(int v, int i = 1, int a = 0, int b = mxn) {
    if (val[i] < v) return b;
    if (a + 1 == b) return a;
    pushdown(i);
    int m = (a + b) >> 1;
    if (val[i << 1] >= v)
      return find(v, i << 1, a, m);
    else
      return find(v, i << 1 | 1, m, b);
  }
  int get(int x, int i = 1, int a = 0, int b = mxn) {
    if (a + 1 == b) return val[i];
    pushdown(i);
    int m = (a + b) >> 1;
    if (x < m)
      return get(x, i << 1, a, m);
    else
      return get(x, i << 1 | 1, m, b);
  }
} seg;
int main() {
  scanf("%d %d %d", &n, &k, &l);
  for (int i = 0; i < (int)(n); ++i)
    scanf("%d %d %d", &x[i], &y[i], &c[i]), yid[i] = i, --c[i];
  sort(yid, yid + n, compy);
  int ans = 0;
  for (int L = 0; L < (int)(n); ++L) {
    int vL = y[yid[L]] - (L ? y[yid[L - 1]] : -1);
    for (int i = L; i < n; ++i) xid[i - L] = yid[i];
    sort(xid, xid + n - L, compx);
    for (int i = 0; i < (int)(n - L); ++i) xre[xid[i]] = i;
    set<int> lsts;
    memset(lst, -1, sizeof(lst));
    for (int i = 0; i < (int)(n - L); ++i) {
      lsts.erase(lst[c[xid[i]]]);
      pre[i] = lst[c[xid[i]]];
      nex[i] = n - L;
      if (lst[c[xid[i]]] != -1) nex[lst[c[xid[i]]]] = i;
      lsts.insert(lst[c[xid[i]]] = i);
      p[i] = lsts.size() == k ? x[xid[*lsts.begin()]] + 1 : 0;
      py[i] = (i + 1 == n - L ? l : x[xid[i + 1]]) - x[xid[i]];
    }
    seg.build(p, py, n - L);
    for (int R = n - 1; R >= L; --R) {
      int vR = (R + 1 == n ? l : y[yid[R + 1]]) - y[yid[R]];
      (ans += 1LL * vL * vR % mod * seg.sum[1] % mod) %= mod;
      int nw = xre[yid[R]], pr = pre[nw], ne = nex[nw];
      int lb = max(nw, seg.find(pr != -1 ? x[xid[pr]] + 1 : 0));
      if (lb < ne) seg.upd(lb, ne, pr != -1 ? x[xid[pr]] + 1 : 0);
      pre[ne] = pr;
      nex[pr] = ne;
    }
  }
  printf("%d\n", ans);
  return 0;
}