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>
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;
using namespace std;
int cx[4] = {0, 0, 1, -1};
int cy[4] = {-1, 1, 0, 0};
string Yes[2] = {"No\n", "Yes\n"};
string YES[2] = {"NO\n", "YES\n"};
string Possible[2] = {"Impossible\n", "Possible\n"};
string POSSIBLE[2] = {"IMPOSSIBLE\n", "POSSIBLE\n"};
struct Tree {
  vector<long long> a, b;
  int sz = 0;
  long long L;
  long long C;
  vector<long long> tree, push, mnA, mxA, sB;
  void Build(int L, int R, int V) {
    if (L + 1 == R) {
      tree[V] = a[L] * b[L] % MOD;
      mnA[V] = a[L];
      mxA[V] = a[L];
      sB[V] = b[L];
      return;
    }
    int M = (L + R) / 2;
    Build(L, M, 2 * V + 1);
    Build(M, R, 2 * V + 2);
    tree[V] = (tree[2 * V + 1] + tree[2 * V + 2]) % MOD;
    sB[V] = (sB[2 * V + 1] + sB[2 * V + 2]) % MOD;
    mnA[V] = min(mnA[2 * V + 1], mnA[2 * V + 2]);
    mxA[V] = max(mxA[2 * V + 1], mxA[2 * V + 2]);
  }
  Tree(vector<long long> _a, vector<long long> _b, long long _L) {
    sz = _a.size();
    tree.resize(4 * sz);
    push.resize(4 * sz, -1);
    mnA.resize(4 * sz);
    mxA.resize(4 * sz);
    sB.resize(4 * sz);
    a = _a;
    b = _b;
    L = _L;
    C = 0;
    for (int i = 0; i < b.size(); i++) C = (C + b[i]) % MOD;
    C = C * L % MOD;
    Build(0, sz, 0);
  }
  long long Get() {
    long long res = -tree[0];
    return ((C + res) % MOD + MOD) % MOD;
  }
  void Push(int V, int L, int M, int R) {
    if (push[V] != -1) {
      push[2 * V + 1] = push[2 * V + 2] = push[V];
      mnA[2 * V + 1] = mnA[2 * V + 2] = push[V];
      mxA[2 * V + 1] = mxA[2 * V + 2] = push[V];
      tree[2 * V + 1] = sB[2 * V + 1] * push[V] % MOD;
      tree[2 * V + 2] = sB[2 * V + 2] * push[V] % MOD;
      push[V] = -1;
    }
  }
  void Set(int l, int r, long long x, int L, int R, int V) {
    int M = (L + R) / 2;
    if (L + 1 != R) Push(V, L, M, R);
    if (r <= L || R <= l) return;
    if (l <= L && R <= r && mxA[V] <= x) {
      mxA[V] = x;
      mnA[V] = x;
      tree[V] = sB[V] * x % MOD;
      push[V] = x;
      return;
    }
    if (L + 1 == R) return;
    Set(l, r, x, L, M, 2 * V + 1);
    if (x > mnA[2 * V + 2]) Set(l, r, x, M, R, 2 * V + 2);
    tree[V] = (tree[2 * V + 1] + tree[2 * V + 2]) % MOD;
    mnA[V] = min(mnA[2 * V + 1], mnA[2 * V + 2]);
    mxA[V] = max(mxA[2 * V + 1], mxA[2 * V + 2]);
  }
  void Set(long long L, long long R, long long x) {
    Set(L, R + 1, x, 0, sz, 0);
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k, L;
  cin >> n >> k >> L;
  struct candy {
    int x, y, c, id;
  };
  vector<candy> A(n);
  for (int i = 0; i < n; i++) cin >> A[i].x >> A[i].y >> A[i].c, A[i].c--;
  sort((A).begin(), (A).end(), [&](candy A, candy B) { return A.y < B.y; });
  for (int i = 0; i < n; i++) A[i].id = i;
  long long ans = 0;
  for (int lowest = 0; lowest < n; lowest++) {
    long long Down = A[lowest].y - (lowest ? A[lowest - 1].y : -1);
    vector<candy> omega;
    vector<set<int> > positions(k);
    for (int i = lowest; i < n; i++) omega.push_back(A[i]);
    sort((omega).begin(), (omega).end(),
         [&](candy A, candy B) { return A.x < B.x; });
    map<int, int> S;
    int j = -1;
    vector<int> nxt(omega.size());
    vector<int> pos(n);
    for (int i = 0; i < omega.size(); i++) {
      pos[omega[i].id] = i;
      positions[omega[i].c].insert(i);
      while (j + 1 < omega.size() && S.size() != k) {
        S[omega[j + 1].c]++;
        j++;
      }
      if (S.size() != k) {
        j = omega.size();
      }
      nxt[i] = j;
      S[omega[i].c]--;
      if (S[omega[i].c] == 0) S.erase(omega[i].c);
    }
    vector<long long> a(omega.size()), b(omega.size());
    for (int j = 0; j < omega.size(); j++) {
      if (nxt[j] == omega.size())
        a[j] = L;
      else
        a[j] = omega[nxt[j]].x;
      b[j] = omega[j].x - (j ? omega[j - 1].x : -1);
    }
    Tree T(a, b, L);
    for (int i = n - 1; i >= lowest; i--) {
      long long cur = (i + 1 < n ? A[i + 1].y : L) - A[i].y;
      long long res = 0;
      res = T.Get();
      int pos_omega = pos[i];
      int color = A[i].c;
      auto it = positions[color].find(pos_omega);
      assert(it != positions[color].end());
      int Pr = -1;
      if (it != positions[color].begin()) {
        it--;
        Pr = *it;
        it++;
      }
      int Nxt = omega.size();
      it++;
      if (it != positions[color].end()) {
        Nxt = *it;
      }
      it--;
      T.Set(Pr + 1, pos_omega, (Nxt == omega.size() ? L : omega[Nxt].x));
      positions[color].erase(it);
      ans = (ans + cur * Down % MOD * res) % MOD;
    }
  }
  cout << ans;
}