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;
int x[2000], y[2000], c[2000];
vector<int> poss;
multiset<int> xx[2000];
vector<pair<int, int> > events;
map<pair<int, int>, int> M;
long long int sum = 0, ans = 0;
int update(int e, int m) {
  if (e < 0) return 0;
  auto it = M.upper_bound(make_pair(e, 2e9));
  it--;
  if (it->first.second != e) {
    pair<int, int> p = it->first;
    int v = it->second;
    M.erase(it);
    M[make_pair(p.first, e)] = v;
    M[make_pair(e + 1, p.second)] = v;
  }
  it = M.upper_bound(make_pair(e, 2e9));
  it--;
  if (it->second < m) return 0;
  pair<int, int> p = make_pair(e, e);
  while (it->second >= m) {
    p.first = it->first.first;
    sum -= (long long int)(it->first.second - it->first.first + 1) * it->second;
    it = M.erase(it);
    if (it == M.begin())
      break;
    else
      it--;
  }
  M[p] = m;
  sum += (long long int)(p.second - p.first + 1) * m;
  return 0;
}
int main() {
  int i;
  int n, k, L;
  scanf("%d %d %d", &n, &k, &L);
  poss.push_back(-1), poss.push_back(L);
  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &x[i], &y[i], &c[i]), c[i]--;
    poss.push_back(y[i]);
  }
  sort(poss.begin(), poss.end());
  poss.resize(unique(poss.begin(), poss.end()) - poss.begin());
  int j;
  for (i = 1; i < poss.size(); i++) {
    int yy = poss[i] - poss[i - 1];
    for (j = 0; j < n; j++) {
      if (y[j] > poss[i - 1]) {
        events.push_back(make_pair(y[j], j));
        xx[c[j]].insert(x[j]);
      }
    }
    M.clear();
    M[make_pair(0, L - 1)] = L, sum = (long long int)L * L;
    for (j = 0; j < k; j++) {
      if (xx[j].empty()) break;
      int p = -1;
      for (auto it = xx[j].begin(); it != xx[j].end(); it++)
        update(*it - 1, p + 1), p = *it;
      update(L - 1, p + 1);
    }
    if (j < k) break;
    sort(events.begin(), events.end(), greater<pair<int, int> >());
    int l = L;
    for (j = 0; j < events.size(); j++) {
      int u = events[j].second;
      long long int nn = (long long int)yy * (l - events[j].first);
      nn %= 1000000007;
      ans += nn * (sum % 1000000007), ans %= 1000000007;
      auto it = xx[c[u]].lower_bound(x[u]);
      it = xx[c[u]].erase(it);
      int a = (it == xx[c[u]].end()) ? L - 1 : *it - 1;
      int b = (it == xx[c[u]].begin()) ? 0 : *(--it) + 1;
      update(a, b);
      if (xx[c[u]].empty()) break;
      l = events[j].first;
    }
    for (j = 0; j < k; j++) xx[j].clear();
    events.clear();
  }
  printf("%I64d\n", ans);
  return 0;
}