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 INF = 0x3f3f3f3f;
const int mod = 1000000007;
vector<int> allx, ally;
int X[2010], Y[2010], C[2010];
long long dist[2010];
int init[2010];
vector<pair<int, int> > node[2010];
vector<int> tmp[2010];
multiset<int> S[2010];
int nxt[2010];
struct Segment_tree {
  int min1[8000], min2[8000], tag[8000];
  long long sum1[8000];
  long long T[8000];
  void pushup(int now) {
    if (min1[now << 1] < min1[now << 1 | 1]) {
      min1[now] = min1[now << 1], sum1[now] = sum1[now << 1];
      min2[now] = min(min2[now << 1], min1[now << 1 | 1]);
    } else if (min1[now << 1] > min1[now << 1 | 1]) {
      min1[now] = min1[now << 1 | 1], sum1[now] = sum1[now << 1 | 1];
      min2[now] = min(min2[now << 1 | 1], min1[now << 1]);
    } else {
      min1[now] = min1[now << 1],
      sum1[now] = sum1[now << 1] + sum1[now << 1 | 1];
      min2[now] = min(min2[now << 1], min2[now << 1 | 1]);
    }
    T[now] = T[now << 1] + T[now << 1 | 1];
  }
  void pushdown(int now) {
    add_tag(now << 1, tag[now]), add_tag(now << 1 | 1, tag[now]);
  }
  void add_tag(int now, int x) {
    if (x <= min1[now]) return;
    if (x < min2[now]) {
      tag[now] = max(tag[now], x);
      T[now] += 1ll * (x - min1[now]) * sum1[now];
      min1[now] = x;
      return;
    }
    add_tag(now << 1, x), add_tag(now << 1 | 1, x);
    pushup(now);
  }
  void Build(int now, int l, int r) {
    tag[now] = -1;
    if (l == r) {
      min1[now] = init[l], min2[now] = INF, sum1[now] = dist[l],
      T[now] = 1ll * dist[l] * init[l];
      return;
    }
    int mid = l + r >> 1;
    Build(now << 1, l, mid), Build(now << 1 | 1, mid + 1, r);
    pushup(now);
  }
  void Update(int now, int l, int r, int L, int R, int x) {
    if (l == L && r == R) {
      add_tag(now, x);
      return;
    }
    pushdown(now);
    int mid = l + r >> 1;
    if (R <= mid)
      Update(now << 1, l, mid, L, R, x);
    else if (L > mid)
      Update(now << 1 | 1, mid + 1, r, L, R, x);
    else
      Update(now << 1, l, mid, L, mid, x),
          Update(now << 1 | 1, mid + 1, r, mid + 1, R, x);
    pushup(now);
  }
  long long Query() { return T[1]; }
} seg;
int main() {
  int n, k, L;
  scanf("%d%d%d", &n, &k, &L);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &X[i], &Y[i], &C[i]);
    X[i]++, Y[i]++;
    allx.push_back(X[i]), ally.push_back(Y[i]);
  }
  sort(allx.begin(), allx.end()),
      allx.resize(unique(allx.begin(), allx.end()) - allx.begin());
  sort(ally.begin(), ally.end()),
      ally.resize(unique(ally.begin(), ally.end()) - ally.begin());
  for (int i = 0; i < n; i++) {
    X[i] = lower_bound(allx.begin(), allx.end(), X[i]) - allx.begin();
    Y[i] = lower_bound(ally.begin(), ally.end(), Y[i]) - ally.begin();
    node[X[i]].push_back(make_pair(Y[i], C[i]));
  }
  for (int i = 0; i < ally.size(); i++) {
    dist[i] = ally[i] - (i ? ally[i - 1] : 0);
  }
  long long ans = 0;
  for (int i = 0; i < allx.size(); i++) {
    for (int j = 0; j < ally.size(); j++) {
      tmp[j].clear();
    }
    for (int j = 0; j <= i; j++) {
      for (int k = 0; k < node[j].size(); k++) {
        int x = node[j][k].first, y = node[j][k].second;
        S[y].insert(x);
        tmp[x].push_back(y);
      }
    }
    multiset<int> SSS;
    for (int j = 1; j <= k; j++) {
      nxt[j] = L + 1;
      SSS.insert(-nxt[j]);
    }
    for (int j = ally.size() - 1; j >= 0; j--) {
      for (auto x : tmp[j]) {
        SSS.erase(SSS.find(-nxt[x]));
        nxt[x] = j;
        SSS.insert(-nxt[x]);
      }
      init[j] = -(*SSS.begin());
      if (init[j] != L + 1) init[j] = ally[init[j]];
    }
    seg.Build(1, 0, ally.size() - 1);
    int LEN = (i + 1 == allx.size() ? L + 1 - allx[i] : allx[i + 1] - allx[i]);
    for (int j = 0; j <= i; j++) {
      long long len = 1ll * (allx[j] - (j ? allx[j - 1] : 0)) * LEN % mod;
      ans =
          (ans + (1ll * ally.back() * (L + 1) - seg.Query()) % mod * len) % mod;
      for (auto it : node[j]) {
        int x = it.first, y = it.second;
        S[y].erase(S[y].find(x));
        if (!S[y].count(x)) {
          auto pos = S[y].lower_bound(x);
          int val = (pos == S[y].end() ? L + 1 : ally[*pos]);
          if (pos == S[y].begin()) {
            seg.Update(1, 0, ally.size() - 1, 0, x, val);
          } else {
            pos--;
            seg.Update(1, 0, ally.size() - 1, *pos + 1, x, val);
          }
        }
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}