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 T>
void chmin(T &x, const T &y) {
  if (x > y) x = y;
}
template <typename T>
void chmax(T &x, const T &y) {
  if (x < y) x = y;
}
int read() {
  char c;
  while ((c = getchar()) < '-')
    ;
  if (c == '-') {
    int x = (c = getchar()) - '0';
    while ((c = getchar()) >= '0') x = x * 10 + c - '0';
    return -x;
  }
  int x = c - '0';
  while ((c = getchar()) >= '0') x = x * 10 + c - '0';
  return x;
}
const int N = 2000 + 5, D = 1e9 + 7;
void split(map<int, int> &Map, int x) {
  auto it = --Map.lower_bound(x + 1);
  Map[x] = it->second;
}
namespace A {
map<int, int> Map;
int64_t sum;
void upd(const pair<int, int> &pr) {
  int nx = pr.first + 1, ny = pr.second;
  if (nx <= Map.begin()->first) return;
  split(Map, nx);
  while (1) {
    auto it = --Map.lower_bound(nx);
    if (it->second >= ny) {
      if (nx <= pr.first) {
        (sum += 1LL * (pr.first - nx + 1) * ny) %= D;
        Map[nx] = ny;
      }
      break;
    }
    (sum -= 1LL * (nx - it->first) * it->second) %= D;
    nx = it->first;
    if (it == Map.begin()) {
      (sum += 1LL * (pr.first - nx + 1) * ny) %= D;
      it->second = ny;
      break;
    }
    Map.erase(it);
  }
}
};  // namespace A
struct Candy {
  int x, y, c;
};
Candy candy[N];
int main() {
  int n, k, L;
  cin >> n >> k >> L;
  for (int i = 1; i <= n; ++i) {
    candy[i].x = read();
    candy[i].y = read();
    candy[i].c = read() - 1;
  }
  sort(candy + 1, candy + n + 1,
       [&](const Candy &a, const Candy &b) { return a.x < b.x; });
  candy[0].x = -1;
  int64_t ans = 0;
  for (int i = n; i >= 1; --i)
    if (candy[i].x > candy[i - 1].x) {
      int now_x = candy[i].x;
      sort(candy + i, candy + n + 1,
           [&](const Candy &a, const Candy &b) { return a.y < b.y; });
      vector<vector<pair<int, int>>> q(k);
      for (int i = 0; i <= k - 1; ++i)
        q[i].push_back(pair<int, int>(now_x, L + 1));
      vector<vector<pair<int, int>>> events(n + 1);
      for (int j = n; j >= i; --j) {
        int nx = candy[j].x + 1, ny = candy[j].y + 1;
        auto &nq = q[candy[j].c];
        int last_x = L + 1;
        while (nq.back().first > nx) {
          events[j].push_back(pair<int, int>(last_x - 1, nq.back().second));
          last_x = nq.back().first;
          nq.pop_back();
        }
        events[j].push_back(pair<int, int>(last_x - 1, nq.back().second));
        if (nq.back().first == nx)
          nq.back().second = ny;
        else
          nq.push_back(pair<int, int>(nx, ny));
      }
      A::Map.clear();
      A::Map[now_x] = 0;
      A::sum = 0;
      for (int i = 0; i <= k - 1; ++i) {
        int last_x = L + 1;
        for (auto it = q[i].end(); --it >= q[i].begin();) {
          A::upd(pair<int, int>(last_x - 1, it->second));
          last_x = it->first;
        }
      }
      int last_y = -1;
      for (int j = i; j <= n; ++j) {
        (ans += (1LL * (L - now_x + 1) * (L + 1) - A::sum) % D *
                (now_x - candy[i - 1].x) % D * (candy[j].y - last_y)) %= D;
        last_y = candy[j].y;
        for (auto pr : events[j]) A::upd(pr);
      }
    }
  cout << (ans % D + D) % D << endl;
}