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;
std::mt19937 rnd(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXP = 2000;
const int MAXCOL = 2000;
const int MOD = 1000000007;
struct P {
  int x, y, col;
};
void inc(int &a, int b) {
  if ((a += b) >= MOD) a -= MOD;
}
void dec(int &a, int b) { inc(a, MOD - b); }
int np, ncol, sz;
P p[MAXP];
int xx[MAXP], nxx;
int yy[MAXP], nyy;
int lwx[MAXP], rwx[MAXP];
int uwy[MAXP], dwy[MAXP];
int sumlwx[MAXP + 1], sumrwx[MAXP + 1];
map<int, int> colx[MAXCOL];
map<int, int> func;
int funcval;
int calcseg(int lo, int hi, int v) {
  return (long long)sumlwx[v + 1] * (sumrwx[hi + 1] - sumrwx[lo]) % MOD;
}
void updatefunc(int upto, int lim) {
  auto it = func.upper_bound(upto);
  int from = INT_MAX;
  while (true) {
    auto nit = it;
    it = it == func.begin() ? func.end() : prev(it);
    int nxt = nit == func.end() ? nxx : nit->first;
    if (nit != func.end() && nit->first <= upto) func.erase(nit);
    if (it == func.end()) break;
    if (it->second < lim) break;
    from = it->first;
    dec(funcval, calcseg(it->first, nxt - 1, it->second));
    if (upto + 1 <= nxt - 1) {
      func[upto + 1] = it->second;
      inc(funcval, calcseg(upto + 1, nxt - 1, it->second));
    }
  }
  if (from <= upto) {
    func[from] = lim;
    inc(funcval, calcseg(from, upto, lim));
  }
}
int solve() {
  nxx = 0;
  for (int i = (0); i < (np); ++i) xx[nxx++] = p[i].x;
  sort(xx, xx + nxx);
  nxx = unique(xx, xx + nxx) - xx;
  for (int i = (0); i < (np); ++i)
    p[i].x = lower_bound(xx, xx + nxx, p[i].x) - xx;
  nyy = 0;
  for (int i = (0); i < (np); ++i) yy[nyy++] = p[i].y;
  sort(yy, yy + nyy);
  nyy = unique(yy, yy + nyy) - yy;
  for (int i = (0); i < (np); ++i)
    p[i].y = lower_bound(yy, yy + nyy, p[i].y) - yy;
  for (int i = (0); i < (nxx); ++i)
    lwx[i] = i == 0 ? xx[i] + 1 : xx[i] - xx[i - 1];
  for (int i = (0); i < (nxx); ++i)
    rwx[i] = i == nxx - 1 ? sz - xx[i] : xx[i + 1] - xx[i];
  for (int i = (0); i < (nyy); ++i)
    dwy[i] = i == 0 ? yy[i] + 1 : yy[i] - yy[i - 1];
  for (int i = (0); i < (nyy); ++i)
    uwy[i] = i == nyy - 1 ? sz - yy[i] : yy[i + 1] - yy[i];
  sumlwx[0] = 0;
  for (int i = (0); i < (nxx); ++i) sumlwx[i + 1] = sumlwx[i] + lwx[i];
  sumrwx[0] = 0;
  for (int i = (0); i < (nxx); ++i) sumrwx[i + 1] = sumrwx[i] + rwx[i];
  int ret = 0;
  for (int top = (0); top < (nyy); ++top) {
    vector<int> xord;
    for (int i = (0); i < (np); ++i)
      if (p[i].y <= top) xord.push_back(i);
    sort(xord.begin(), xord.end(),
         [&](const int &a, const int &b) { return p[a].x < p[b].x; });
    vector<int> colcnt(ncol, 0);
    int havecol = 0;
    int l = 0, r = 0;
    func.clear();
    func[0] = -1;
    while (true) {
      while (r < ((int)(xord).size()) &&
             (havecol < ncol || p[xord[r]].x == p[xord[r - 1]].x)) {
        int idx = xord[r++];
        if (colcnt[p[idx].col]++ == 0) ++havecol;
      }
      int rx = p[xord[r - 1]].x;
      if (havecol < ncol) break;
      while (true) {
        int idx = xord[l];
        if (colcnt[p[idx].col] == 1) break;
        --colcnt[p[idx].col];
        ++l;
      }
      int lx = p[xord[l]].x;
      func[rx] = lx;
      while (l < r && p[xord[l]].x == lx) {
        int idx = xord[l++];
        if (--colcnt[p[idx].col] == 0) --havecol;
      }
    }
    funcval = 0;
    for (auto it = func.begin(); it != func.end(); ++it) {
      auto nit = next(it);
      inc(funcval,
          calcseg(it->first, nit == func.end() ? nxx - 1 : nit->first - 1,
                  it->second));
    }
    for (int i = (0); i < (ncol); ++i) colx[i].clear();
    for (int i = (0); i < (np); ++i)
      if (p[i].y <= top) ++colx[p[i].col][p[i].x];
    vector<int> remord;
    for (int i = (0); i < (np); ++i)
      if (p[i].y <= top) remord.push_back(i);
    sort(remord.begin(), remord.end(),
         [&](const int &a, const int &b) { return p[a].y < p[b].y; });
    int atrem = 0;
    for (int bot = (0); bot <= (top); ++bot) {
      ret = (ret + (long long)funcval * dwy[bot] % MOD * uwy[top]) % MOD;
      while (atrem < ((int)(remord).size()) && p[remord[atrem]].y == bot) {
        int idx = remord[atrem++];
        map<int, int> &mp = colx[p[idx].col];
        auto it = mp.find(p[idx].x);
        assert(it != mp.end());
        if (it->second >= 2) {
          --it->second;
        } else {
          assert(it->second == 1);
          auto nit = next(it);
          int lim = it == mp.begin() ? -1 : prev(it)->first;
          int upto = nit == mp.end() ? nxx - 1 : nit->first - 1;
          updatefunc(upto, lim);
          mp.erase(it);
        }
      }
    }
  }
  return ret;
}
void run() {
  scanf("%d%d%d", &np, &ncol, &sz);
  for (int i = (0); i < (np); ++i)
    scanf("%d%d%d", &p[i].x, &p[i].y, &p[i].col), --p[i].col;
  printf("%d\n", solve());
}
int main() {
  run();
  return 0;
}