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;
const int mod = 1e9 + 7;
int main() {
  int n, k, L;
  cin >> n >> k >> L;
  map<int, int> sex, sey;
  vector<int> cx, cy;
  int ar[n][3];
  for (int a = 0; a < n; a++) {
    cin >> ar[a][0] >> ar[a][1] >> ar[a][2];
    ar[a][2]--;
    sex[ar[a][0]] = 0, sey[ar[a][1]] = 0;
  }
  for (auto it = sex.begin(); it != sex.end(); it++) {
    (*it).second = cx.size();
    cx.push_back((*it).first);
  }
  for (auto it = sey.begin(); it != sey.end(); it++) {
    (*it).second = cy.size();
    cy.push_back((*it).first);
  }
  vector<pair<int, int> > sp[cx.size()];
  for (int a = 0; a < n; a++) {
    sp[sex[ar[a][0]]].push_back({ar[a][1], ar[a][2]});
  }
  for (int a = 0; a < cx.size(); a++) {
    if (a) {
      for (int b = 0; b < sp[a].size(); b++) {
        sp[a - 1].push_back({L, sp[a][b].second});
      }
    }
  }
  for (int a = 0; a < k; a++) sp[cx.size() - 1].push_back({L, a});
  for (int a = 0; a < cx.size(); a++) sort(sp[a].begin(), sp[a].end());
  int an = 0;
  for (int a = 0; a < cy.size(); a++) {
    vector<pair<int, int> > st[k], add[cx.size()];
    for (int b = 0; b < k; b++) st[b].push_back({0, L});
    for (int b = cx.size() - 1; b >= 0; b--) {
      for (int c = 0; c < sp[b].size(); c++) {
        int y = sp[b][c].first, i = sp[b][c].second;
        if (y >= cy[a] and st[i].back().second != cx[b]) {
          while (st[i].back().first > y) {
            int y2 = st[i].back().first;
            st[i].pop_back();
            int x2 = st[i].back().second;
            add[b + 1].push_back({y2, x2});
          }
          st[i].push_back({y, cx[b]});
        }
      }
    }
    for (int b = 0; b < k; b++) {
      while (st[b].size() > 1) {
        int y2 = st[b].back().first;
        st[b].pop_back();
        int x2 = st[b].back().second;
        add[0].push_back({y2, x2});
      }
    }
    map<int, pair<int, int>, greater<int> > ma;
    ma[0] = {L + 1, L + 2};
    long long su = 0;
    for (int b = 0; b < cx.size(); b++) {
      add[b].push_back({L, cx[b]});
      while (add[b].size()) {
        int y = add[b].back().first, x = add[b].back().second, q = 0;
        add[b].pop_back();
        auto it = ma.lower_bound(y), start = it;
        while (1) {
          int y2 = (*it).first, x2 = (*it).second.first,
              q2 = (*it).second.second;
          if (x >= x2) {
            su += 1ll * q2 * (y - y2);
            q += q2;
            it++;
          } else {
            if (y > y2) {
              int d = max(0, q2 - (x2 - x));
              su += 1ll * d * (y - y2);
              q += d;
              (*it).second.second -= d;
            }
            break;
          }
        }
        ma.erase(start, it);
        if (q) ma[y] = {x, q};
      }
      int d = (1ll * L * (L + 1) - su) % mod;
      d = 1ll * d * (b ? cx[b] - cx[b - 1] : cx[b] + 1) % mod;
      d = 1ll * d * (a ? cy[a] - cy[a - 1] : cy[a] + 1) % mod;
      an = (an + d) % mod;
    }
  }
  cout << an;
}