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 <class T>
void print(T& x) {
  cout << x;
}
template <class T, class U>
void print(pair<T, U>& p) {
  cout << "(";
  print(p.first);
  cout << ", ";
  print(p.second);
  cout << ")";
}
template <class T>
void print(vector<T>& v) {
  cout << "{";
  if (((int)(v).size())) print(v[0]);
  for (int i = 1; i < ((int)(v).size()); i++) cout << ", ", print(v[i]);
  cout << "}\n";
}
const int n = 1e4 + 10;
const long long MOD = 1e9 + 7;
long long N, K, L;
multiset<int> C[n];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> K >> L;
  vector<tuple<int, int, int>> E;
  E.emplace_back(-1, -1, -1);
  for (int i = 0; i < N; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    c--;
    E.emplace_back(x, y, c);
  }
  E.emplace_back(L, -1, -1);
  sort(E.begin(), E.end());
  long long res = 0;
  for (int ei = 1; ei < ((int)(E).size()) - 1; ei++) {
    for (int i = 0; i < K; i++) {
      C[i].clear();
      C[i].insert(-1);
      C[i].insert(L);
    }
    vector<pair<int, int>> A;
    for (int i = 1; i <= ei; i++) {
      auto [x, y, c] = E[i];
      C[c].insert(y);
      A.emplace_back(y, c);
    }
    sort(A.begin(), A.end());
    int cur = -1;
    for (int i = 0; i < K; i++) cur = max(cur, *(++(C[i].begin())));
    long long curPos = 0;
    set<pair<int, int>> S;
    S.insert({-1, 0});
    for (int ai = 0; ai < ((int)(A).size()); ai++) {
      auto [y, c] = A[ai];
      if (ai == 0 || y != A[ai - 1].first) {
        (curPos += ((long long)(L - cur)) * (y - (--(S.end()))->first)) %= MOD;
        S.insert({y, cur});
      }
      cur = max(cur, *(C[c].upper_bound(y)));
    }
    S.insert({L, L});
    for (int i = 1; i <= ei; i++) {
      auto [x, y, c] = E[i];
      long long wl = (get<0>(E[i]) - get<0>(E[i - 1]));
      long long wr = (get<0>(E[ei + 1]) - get<0>(E[ei]));
      (res += curPos * wl % MOD * wr) %= MOD;
      int yPrev = *(--(C[c].lower_bound(y)));
      auto it = --(S.upper_bound(make_pair(yPrev, L + 5)));
      if (it->first != yPrev) {
        S.insert(make_pair(yPrev, (++it)->second));
        it = S.upper_bound(make_pair(yPrev, L + 5));
      } else
        it++;
      int newTo = *(++(C[c].lower_bound(y)));
      int lst = yPrev;
      while (it->second < newTo) {
        (curPos +=
         MOD - ((long long)(it->first - lst)) * (L - it->second) % MOD) %= MOD;
        lst = it->first;
        auto it2 = it++;
        S.erase(it2);
      }
      if (lst != yPrev) {
        S.insert({lst, newTo});
        (curPos += ((long long)(lst - yPrev)) * (L - newTo)) %= MOD;
      }
      C[c].erase(C[c].find(y));
    }
  }
  cout << res << endl;
}