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;
template <typename _T>
inline void read(_T &f) {
  f = 0;
  _T fu = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') {
      fu = -1;
    }
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    f = (f << 3) + (f << 1) + (c & 15);
    c = getchar();
  }
  f *= fu;
}
template <typename T>
void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x < 10)
    putchar(x + 48);
  else
    print(x / 10), putchar(x % 10 + 48);
}
template <typename T>
void print(T x, char t) {
  print(x);
  putchar(t);
}
const int N = 2005, md = 1e9 + 7;
inline int add(int x, int y) {
  x += y;
  if (x >= md) x -= md;
  return x;
}
inline int sub(int x, int y) {
  x -= y;
  if (x < 0) x += md;
  return x;
}
inline int mul(int x, int y) { return 1ll * x * y % md; }
inline int fpow(int x, int y) {
  int ans = 1;
  while (y) {
    if (y & 1) ans = mul(ans, x);
    y >>= 1;
    x = mul(x, x);
  }
  return ans;
}
struct node_t {
  int l, r, maxn, tag, sum, len;
} p[N << 2];
multiset<int> pos[N], now;
vector<int> col[N];
vector<pair<int, int> > po[N];
int xb[N], yb[N], x[N], y[N], c[N], r[N], las[N];
int n, k, L, xl, yl, ans;
void update(int u) {
  p[u].maxn = max(p[u << 1].maxn, p[u << 1 | 1].maxn);
  p[u].sum = add(p[u << 1].sum, p[u << 1 | 1].sum);
  p[u].len = p[u << 1].len + p[u << 1 | 1].len;
}
void add_tag(int u, int x) {
  p[u].maxn = p[u].tag = x;
  p[u].sum = mul(p[u].len, x);
}
void pushdown(int u) {
  if (p[u].tag) {
    add_tag(u << 1, p[u].tag);
    add_tag(u << 1 | 1, p[u].tag);
    p[u].tag = 0;
  }
}
void build(int u, int l, int r) {
  p[u].l = l;
  p[u].r = r;
  p[u].tag = 0;
  if (l == r) {
    p[u].len = yb[l] - yb[l - 1];
    p[u].maxn = ::r[l];
    p[u].sum = mul(p[u].len, ::r[l]);
    return;
  }
  int mid = (l + r) >> 1;
  build(u << 1, l, mid);
  build(u << 1 | 1, mid + 1, r);
  update(u);
}
void change(int u, int l, int r, int x) {
  if (l <= p[u].l && p[u].r <= r) {
    if (p[u].maxn <= x) {
      add_tag(u, x);
      return;
    }
    if (p[u].l == p[u].r) return;
    pushdown(u);
    change(u << 1, l, r, x);
    change(u << 1 | 1, l, r, x);
    update(u);
    return;
  }
  pushdown(u);
  int mid = (p[u].l + p[u].r) >> 1;
  if (mid >= l) change(u << 1, l, r, x);
  if (mid + 1 <= r) change(u << 1 | 1, l, r, x);
  update(u);
}
int main() {
  read(n);
  read(k);
  read(L);
  for (int i = 1; i <= n; i++) {
    read(x[i]);
    read(y[i]);
    read(c[i]);
    ++x[i];
    ++y[i];
    xb[i] = x[i];
    yb[i] = y[i];
  }
  sort(xb + 1, xb + n + 1);
  xl = unique(xb + 1, xb + n + 1) - xb - 1;
  sort(yb + 1, yb + n + 1);
  yl = unique(yb + 1, yb + n + 1) - yb - 1;
  xb[xl + 1] = yb[yl + 1] = L + 1;
  for (int i = 1; i <= n; i++) {
    x[i] = lower_bound(xb + 1, xb + xl + 1, x[i]) - xb;
    y[i] = lower_bound(yb + 1, yb + yl + 1, y[i]) - yb;
    po[x[i]].emplace_back(y[i], c[i]);
  }
  for (int i = 1; i <= xl; i++) {
    for (int j = 1; j <= yl; j++) col[j].clear();
    for (int j = i; j <= xl; j++) {
      for (auto k : po[j]) {
        col[k.first].push_back(k.second);
      }
    }
    now.clear();
    for (int j = 1; j <= k; j++)
      pos[j].clear(), now.insert(L + 1), las[j] = L + 1;
    for (int j = yl; j >= 1; j--) {
      for (auto k : col[j]) {
        now.erase(now.find(las[k]));
        now.insert(yb[j]);
        las[k] = yb[j];
      }
      auto it = now.end();
      --it;
      r[j] = *it;
    }
    build(1, 1, yl);
    for (int j = i; j <= xl; j++) {
      for (auto k : po[j]) {
        pos[k.second].insert(k.first);
      }
    }
    for (int j = 1; j <= k; j++) pos[j].insert(0), pos[j].insert(yl + 1);
    int lasx = L + 1;
    for (int j = xl; j >= i; j--) {
      ans = add(ans, mul(xb[i] - xb[i - 1],
                         mul(lasx - xb[j], sub(mul(L + 1, yb[yl]), p[1].sum))));
      lasx = xb[j];
      for (auto k : po[j]) {
        pos[k.second].erase(pos[k.second].find(k.first));
        auto it = pos[k.second].lower_bound(k.first);
        if (*it == k.first) continue;
        int tmp = *it;
        --it;
        change(1, *it + 1, k.first, yb[tmp]);
      }
    }
  }
  print(ans, '\n');
  return 0;
}