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 long long mod = 1e9 + 7;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
void print(long long x) {
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
}
struct link {
  int L[N], R[N];
  void del(int x) {
    R[L[x]] = R[x];
    L[R[x]] = L[x];
  }
} S, s;
int n, K, L;
struct P {
  int x, y, c, ny;
} a[N];
bool cmpx(P x, P y) { return x.x < y.x; }
bool cmpy(P x, P y) { return x.y < y.y; }
int sy[N], las[N];
int col[N];
int f[N], t[N];
struct node {
  int l, r, mid;
  int sum, mn, mx, lazy;
  node *ch[2];
  node(int x, int y) : l(x), r(y), mid(l + r >> 1), sum(0) {
    if (x < y) {
      ch[0] = new node(x, mid);
      ch[1] = new node(mid + 1, y);
    } else
      ch[0] = ch[1] = NULL;
  }
  void update(int c) {
    sum = 1ll * (sy[r] - sy[l - 1]) * c % mod;
    lazy = mn = mx = c;
  }
  void pushup() {
    sum = (ch[0]->sum + ch[1]->sum) % mod;
    mn = min(ch[0]->mn, ch[1]->mn);
    mx = max(ch[0]->mx, ch[1]->mx);
  }
  void init() {
    if (l == r) {
      update(f[l]);
      return;
    }
    ch[0]->init();
    ch[1]->init();
    lazy = 0;
    pushup();
  }
  void change(int x, int c) {
    if (mn >= c) return;
    if (mx <= c && l == x) {
      update(c);
      return;
    }
    if (lazy) {
      if (ch[0]) {
        ch[0]->update(lazy);
        ch[1]->update(lazy);
      }
      lazy = 0;
    }
    if (x <= mid) ch[0]->change(x, c);
    ch[1]->change(max(mid + 1, x), c);
    pushup();
  }
} *root = NULL;
long long ans = 0;
int main() {
  scanf("%d%d%d", &n, &K, &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 + 1 + n, 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) {
    sy[i] = a[i].y;
    a[i].ny = i;
  }
  for (int i = 1; i <= n; ++i) {
    int &it = las[a[i].c];
    if (it) {
      s.R[it] = i;
      s.L[i] = it;
    }
    s.R[i] = n + 1;
    it = i;
  }
  sort(a + 1, a + 1 + n, cmpx);
  root = new node(1, n);
  for (int i = 1; i <= n; ++i) {
    if (a[i].x != a[i - 1].x) {
      for (int j = 0; j < i; ++j) col[a[j].ny] = 0;
      for (int j = i; j <= n; ++j) col[a[j].ny] = a[j].c;
      for (int l = 1, r = 1, tot = 0; l <= n; ++l) {
        for (; r <= n && tot < K; ++r) {
          if (col[r] && !t[col[r]]) ++tot;
          t[col[r]]++;
        }
        f[l] = (tot < K ? L : sy[r - 1]);
        --t[col[l]];
        if (col[l] && !t[col[l]]) --tot;
      }
      root->init();
      S = s;
      for (int j = n; j >= 1; j--) {
        ans += 1ll * (1ll * (sy[n] + 1) * L % mod - root->sum + mod) % mod *
               (a[j + 1].x - a[j].x) % mod * (a[i].x - a[i - 1].x) % mod;
        int p = a[j].ny;
        root->change(S.L[p] + 1, sy[S.R[p]]);
        S.del(p);
      }
    }
    s.del(a[i].ny);
  }
  ans = (ans % mod + mod) % mod;
  cout << ans << endl;
  return 0;
}