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 = 2005;
const int MOD = 1000000007;
int n, k, L;
int x[N], y[N], c[N];
int bx[N], totx;
int by[N], toty;
int s[N][N], top[N];
vector<int> point[N];
vector<int> blo[N];
vector<int> pos[N];
struct Segment_Tree {
  struct Node {
    int l, r;
    pair<int, int> Min;
    int smi;
    int sum;
  } tree[N << 2];
  void push_up(int i) {
    int mi = min(tree[i * 2].Min.first, tree[i * 2 + 1].Min.first);
    tree[i].Min = {mi, 0};
    if (tree[i * 2].Min.first == mi)
      tree[i].Min.second += tree[i * 2].Min.second;
    if (tree[i * 2 + 1].Min.first == mi)
      tree[i].Min.second += tree[i * 2 + 1].Min.second;
    tree[i].smi = totx + 1;
    if (tree[i * 2].Min.first != mi)
      tree[i].smi = min(tree[i].smi, tree[i * 2].Min.first);
    if (tree[i * 2 + 1].Min.first != mi)
      tree[i].smi = min(tree[i].smi, tree[i * 2 + 1].Min.first);
    if (tree[i * 2].smi != mi) tree[i].smi = min(tree[i].smi, tree[i * 2].smi);
    if (tree[i * 2 + 1].smi != mi)
      tree[i].smi = min(tree[i].smi, tree[i * 2 + 1].smi);
    tree[i].sum = (tree[i * 2].sum + tree[i * 2 + 1].sum) % MOD;
    return;
  }
  void build(int i, int l, int r) {
    tree[i].l = l, tree[i].r = r;
    if (l == r) {
      tree[i].Min = {0, by[l] - by[l - 1]};
      tree[i].smi = totx + 1;
      tree[i].sum =
          1LL * (L - bx[tree[i].Min.first]) * tree[i].Min.second % MOD;
      return;
    }
    int mid = (l + r) / 2;
    build(i * 2, l, mid);
    build(i * 2 + 1, mid + 1, r);
    push_up(i);
    return;
  }
  void add(int i, int v) {
    if (v <= tree[i].Min.first)
      return;
    else if (v < tree[i].smi) {
      tree[i].sum =
          (tree[i].sum -
           1LL * (L - bx[tree[i].Min.first]) * tree[i].Min.second % MOD +
           1LL * (L - bx[v]) * tree[i].Min.second % MOD + MOD) %
          MOD;
      tree[i].Min.first = v;
    }
    return;
  }
  void push_down(int i) {
    add(i * 2, tree[i].Min.first);
    add(i * 2 + 1, tree[i].Min.first);
    return;
  }
  void modify(int i, int l, int r, int v) {
    if (v <= tree[i].Min.first) return;
    if (l <= tree[i].l && tree[i].r <= r && v < tree[i].smi) return add(i, v);
    if (tree[i].l == tree[i].r) return;
    push_down(i);
    if (l <= tree[i * 2].r) modify(i * 2, l, r, v);
    if (r >= tree[i * 2 + 1].l) modify(i * 2 + 1, l, r, v);
    push_up(i);
    return;
  }
  int query(int i, int l, int r) {
    if (l <= tree[i].l && tree[i].r <= r) return tree[i].sum;
    push_down(i);
    int res = 0;
    if (l <= tree[i * 2].r) res = (res + query(i * 2, l, r)) % MOD;
    if (r >= tree[i * 2 + 1].l) res = (res + query(i * 2 + 1, l, r)) % MOD;
    return res;
  }
  int query(int i, int u) {
    if (tree[i].l == tree[i].r) return tree[i].Min.first;
    push_down(i);
    if (u <= tree[i * 2].r)
      return query(i * 2, u);
    else
      return query(i * 2 + 1, u);
  }
} T;
int main() {
  scanf("%d%d%d", &n, &k, &L);
  for (int i = 1; i <= n; i++) scanf("%d%d%d", &x[i], &y[i], &c[i]);
  for (int i = 1; i <= n; i++) bx[++totx] = x[i];
  bx[++totx] = L;
  sort(bx + 1, bx + totx + 1);
  totx = unique(bx + 1, bx + totx + 1) - bx - 1;
  for (int i = 1; i <= n; i++)
    x[i] = lower_bound(bx + 1, bx + totx + 1, x[i]) - bx;
  for (int i = 1; i <= n; i++) by[++toty] = y[i];
  by[++toty] = L;
  sort(by + 1, by + toty + 1);
  toty = unique(by + 1, by + toty + 1) - by - 1;
  for (int i = 1; i <= n; i++)
    y[i] = lower_bound(by + 1, by + toty + 1, y[i]) - by;
  bx[0] = by[0] = -1;
  for (int i = 1; i <= n; i++) point[c[i]].emplace_back(i);
  for (int i = 1; i <= k; i++)
    sort(point[i].begin(), point[i].end(), [=](const int &a, const int &b) {
      return x[a] != x[b] ? x[a] > x[b] : y[a] < y[b];
    });
  for (int i = 1; i <= n; i++) pos[x[i]].emplace_back(i);
  x[0] = totx, y[0] = toty;
  int ans = 0;
  for (int u = 1; u < toty; u++) {
    for (int i = 1; i <= n; i++) blo[i].clear();
    T.build(1, 1, toty);
    for (int i = 1; i <= k; i++) {
      top[i] = 0;
      s[i][++top[i]] = 0;
      for (int p : point[i])
        if (y[p] <= u) {
          while (top[i] >= 1 && y[p] >= y[s[i][top[i]]])
            blo[p].emplace_back(s[i][top[i]]), top[i]--;
          blo[p].emplace_back(s[i][top[i]]);
          reverse(blo[p].begin(), blo[p].end());
          s[i][++top[i]] = p;
        }
      for (int j = 1; j < top[i]; j++) {
        int v = s[i][j];
        int p = s[i][j + 1];
        T.modify(1, y[p] + 1, y[v], x[v]);
      }
      T.modify(1, 1, y[s[i][top[i]]], x[s[i][top[i]]]);
    }
    for (int i = 1; i < totx; i++) {
      ans = (ans + 1LL * (by[u + 1] - by[u]) * (bx[i] - bx[i - 1]) % MOD *
                       T.query(1, 1, toty) % MOD) %
            MOD;
      for (int p : pos[i])
        if (y[p] <= u) {
          for (int j = 0; j < (int)blo[p].size() - 1; j++) {
            int v = blo[p][j];
            int s = blo[p][j + 1];
            T.modify(1, y[s] + 1, y[v], x[v]);
          }
          T.modify(1, 1, y[blo[p].back()], x[blo[p].back()]);
        }
    }
  }
  printf("%d", ans);
  return 0;
}