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;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
const long long maxn = 2e3 + 10, maxm = 1e2 + 10, lg = 35, mod = 1e9 + 7,
                inf = 1e18;
long long n, k, L, X[maxn], Y[maxn], C[maxn], ans;
vector<long long> cx, cy, xx[maxn];
multiset<long long> cc[maxn];
long long werx(long long x) {
  return lower_bound(cx.begin(), cx.end(), x) - cx.begin();
}
long long wery(long long y) {
  return lower_bound(cy.begin(), cy.end(), y) - cy.begin();
}
long long sum[maxn << 2], mx[maxn << 2], laz[maxn << 2], len[maxn << 2];
void bild(long long s = 1, long long t = (long long)(cy.size()),
          long long v = 1) {
  mx[v] = 0, laz[v] = -1, len[v] = cy[t - 1] - cy[s - 1];
  if (t - s == 1) {
    sum[v] = len[v] * (L - mx[v]) % mod;
    return;
  }
  bild(s, ((s + t) >> 1), (v << 1)), bild(((s + t) >> 1), t, ((v << 1) ^ 1));
  sum[v] = (sum[(v << 1)] + sum[((v << 1) ^ 1)]) % mod;
}
void app(long long v, long long x) {
  if (mx[v] >= x) return;
  mx[v] = laz[v] = x;
  sum[v] = len[v] * (L - mx[v]) % mod;
}
void shift(long long v) {
  app((v << 1), laz[v]), app(((v << 1) ^ 1), laz[v]), laz[v] = -1;
}
void upd(long long l, long long r, long long x, long long s = 1,
         long long t = (long long)(cy.size()), long long v = 1) {
  if (l >= t || r <= s) return;
  if (l <= s && r >= t && mx[v] != -1) return app(v, x);
  shift(v);
  upd(l, r, x, s, ((s + t) >> 1), (v << 1));
  upd(l, r, x, ((s + t) >> 1), t, ((v << 1) ^ 1));
  sum[v] = (sum[(v << 1)] + sum[((v << 1) ^ 1)]) % mod;
  mx[v] = (mx[(v << 1)] == mx[((v << 1) ^ 1)] ? mx[(v << 1)] : -1);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k >> L;
  cx.push_back(-1), cy.push_back(-1);
  cx.push_back(L), cy.push_back(L);
  for (int i = 0; i < n; i++)
    cin >> X[i] >> Y[i] >> C[i], cx.push_back(X[i]), cy.push_back(Y[i]);
  sort(cx.begin(), cx.end()),
      cx.resize(unique(cx.begin(), cx.end()) - cx.begin());
  sort(cy.begin(), cy.end()),
      cy.resize(unique(cy.begin(), cy.end()) - cy.begin());
  for (int i = 0; i < n; i++) xx[werx(X[i])].push_back(i);
  for (int i = 1; i <= k; i++) cc[i].insert(-1), cc[i].insert(L);
  for (int l = 1; l + 1 < (long long)(cx.size()); l++) {
    bild();
    for (int i = 0; i < n; i++)
      if (X[i] >= cx[l]) cc[C[i]].insert(Y[i]);
    for (int c = 1; c <= k; c++) {
      long long yg = -1;
      for (auto y : cc[c]) {
        upd(wery(yg + 1), wery(y + 1), y);
        yg = y;
      }
    }
    for (int r = (long long)(cx.size()) - 2; r >= l; r--) {
      long long xz = (cx[l] - cx[l - 1]) * (cx[r + 1] - cx[r]) % mod;
      (ans += xz * sum[1] % mod) %= mod;
      for (auto i : xx[r]) {
        auto it = cc[C[i]].lower_bound(Y[i]);
        auto pr = it;
        pr--;
        auto nx = it;
        nx++;
        upd(wery((*pr) + 1), wery((*it) + 1), *nx);
        cc[C[i]].erase(it);
      }
    }
  }
  cout << ans;
  return 0;
}