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 T1, typename T2>
inline void chkmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chkmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
using ll = long long;
using ld = long double;
const string FILENAME = "input";
const int MAXN = 8028;
const int Mod = 1000000007;
int sum(int a, int b) { return (a + b >= Mod ? a + b - Mod : a + b); }
int mul(int a, int b) { return ((ll)a * b % Mod); }
int L;
ll d[MAXN * 4];
int len[MAXN * 4];
int last[MAXN * 4];
int mod[MAXN * 4];
void init(int v, int vl, int vr, const vector<int> &xs) {
  len[v] = xs[vr] - xs[vl - 1];
  if (vl < vr) {
    int mid = (vl + vr) >> 1;
    init(v * 2, vl, mid, xs);
    init(v * 2 + 1, mid + 1, vr, xs);
  }
}
void restore(int v, int vl, int vr, const vector<int> &go) {
  mod[v] = -1;
  if (vl == vr) {
    d[v] = (ll)(len[v]) * (L - go[vl]);
    last[v] = go[vl];
    return;
  }
  int mid = (vl + vr) >> 1;
  restore(v * 2, vl, mid, go);
  restore(v * 2 + 1, mid + 1, vr, go);
  d[v] = d[v * 2] + d[v * 2 + 1];
  last[v] = last[v * 2 + 1];
}
void push(int v, int l, int r) {
  if (mod[v] != -1) {
    last[v] = mod[v];
    d[v] = (ll)len[v] * (L - mod[v]);
    if (l < r) {
      mod[v * 2] = mod[v];
      mod[v * 2 + 1] = mod[v];
    }
    mod[v] = -1;
  }
}
void add(int v, int vl, int vr, int l, int r, int pos) {
  push(v, vl, vr);
  if (l > vr || r < vl) {
    return;
  }
  if (l <= vl && vr <= r) {
    mod[v] = pos;
    push(v, vl, vr);
    return;
  }
  int mid = (vl + vr) >> 1;
  add(v * 2, vl, mid, l, r, pos);
  add(v * 2 + 1, mid + 1, vr, l, r, pos);
  d[v] = d[v * 2] + d[v * 2 + 1];
  last[v] = last[v * 2 + 1];
}
int spusk(int v, int vl, int vr, int pos) {
  push(v, vl, vr);
  if (last[v] <= pos) {
    return -1;
  }
  if (vl == vr) {
    return vl;
  }
  int mid = (vl + vr) >> 1;
  int ans = spusk(v * 2, vl, mid, pos);
  if (ans != -1) {
    return ans;
  }
  return spusk(v * 2 + 1, mid + 1, vr, pos);
}
int N, K;
int NX, NY;
int X[MAXN], Y[MAXN], C[MAXN];
vector<int> xs, ys;
int prv[MAXN], nxt[MAXN];
void del(int i) {
  int xprv = (prv[i] == -1 ? -1 : X[prv[i]]);
  int xcur = X[i];
  int xnxt = (nxt[i] == -1 ? L : X[nxt[i]]);
  int l = lower_bound((xs).begin(), (xs).end(), xprv) - xs.begin() + 1;
  int r = spusk(1, 1, NX - 2, xnxt);
  if (r == -1) {
    r = NX - 1;
  }
  r--;
  r = min(r, (int)(lower_bound((xs).begin(), (xs).end(), xcur) - xs.begin()));
  if (l <= r) {
    add(1, 1, NX - 2, l, r, xnxt);
  }
}
bool comp(int i, int j) {
  return make_pair(Y[i], -X[i]) > make_pair(Y[j], -X[j]);
}
void resort() {
  vector<int> order;
  for (int i = 0; i < N; i++) {
    order.push_back(i);
  }
  sort(order.begin(), order.end(), comp);
  vector<int> newX(N), newY(N), newC(N);
  for (int i = 0; i < N; i++) {
    newX[i] = X[order[i]];
    newY[i] = Y[order[i]];
    newC[i] = C[order[i]];
  }
  for (int i = 0; i < N; i++) {
    X[i] = newX[i];
    Y[i] = newY[i];
    C[i] = newC[i];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> K >> L;
  xs = {-1, L};
  ys = {-1, L};
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i] >> C[i];
    C[i]--;
    xs.push_back(X[i]);
    ys.push_back(Y[i]);
  }
  sort((xs).begin(), (xs).end());
  xs.resize(unique((xs).begin(), (xs).end()) - xs.begin());
  sort((ys).begin(), (ys).end());
  ys.resize(unique((ys).begin(), (ys).end()) - ys.begin());
  NX = xs.size();
  NY = ys.size();
  resort();
  init(1, 1, NX - 2, xs);
  int ans = 0;
  for (int yr = 1; yr + 1 < NY; yr++) {
    vector<vector<int> > start(NX);
    for (int i = 0; i < N; i++) {
      if (Y[i] <= ys[yr]) {
        int xi = lower_bound((xs).begin(), (xs).end(), X[i]) - xs.begin();
        start[xi].push_back(C[i]);
      }
    }
    int bad = K;
    vector<int> cnts(K);
    auto inc = [&](int z) {
      if (++cnts[z] == 1) {
        --bad;
      }
    };
    auto dec = [&](int z) {
      if (--cnts[z] == 0) {
        ++bad;
      }
    };
    vector<int> go(NX);
    int uk = 0;
    for (int i = 1; i + 1 < NX; i++) {
      while (bad && uk + 2 < NX) {
        uk++;
        for (auto z : start[uk]) {
          inc(z);
        }
      }
      if (bad) {
        go[i] = L;
      } else {
        go[i] = xs[uk];
      }
      for (auto z : start[i]) {
        dec(z);
      }
    }
    restore(1, 1, NX - 2, go);
    vector<map<int, int> > m(K);
    for (int i = 0; i < N; i++) {
      if (Y[i] <= ys[yr]) {
        auto it = m[C[i]].lower_bound(X[i]);
        if (it == m[C[i]].end()) {
          nxt[i] = -1;
        } else {
          nxt[i] = it->second;
        }
        it = m[C[i]].upper_bound(X[i]);
        if (it == m[C[i]].begin()) {
          prv[i] = -1;
        } else {
          prv[i] = prev(it)->second;
        }
        m[C[i]][X[i]] = i;
      }
    }
    uk = N - 1;
    for (int yl = 1; yl <= yr; yl++) {
      int add = mul(d[1] % Mod, mul(ys[yr + 1] - ys[yr], ys[yl] - ys[yl - 1]));
      ans = sum(ans, add);
      while (uk >= 0 && Y[uk] == ys[yl]) {
        del(uk--);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}