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 Inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
const int jt = 1000000007;
int n, k, L;
int xs, ys;
vector<int> xls, yls, yis[2233];
multiset<int> cls[2233];
int in[2233], dis[2233];
int x[2233], y[2233], c[2233];
vector<pair<int, int> > nds[2233];
int nxt[2233];
struct Segtree {
  int st[8410], nd[8410], tag[8410];
  long long res[8410], sm[8410];
  void inline pu(int now) {
    if (st[now << 1] < st[now << 1 | 1]) {
      st[now] = st[now << 1];
      sm[now] = sm[now << 1];
      nd[now] = min(nd[now << 1], st[now << 1 | 1]);
    } else if (st[now << 1] > st[now << 1 | 1]) {
      st[now] = st[now << 1 | 1];
      sm[now] = sm[now << 1 | 1];
      nd[now] = min(st[now << 1], nd[now << 1 | 1]);
    } else {
      st[now] = st[now << 1];
      sm[now] = sm[now << 1] + sm[now << 1 | 1];
      nd[now] = min(nd[now << 1], nd[now << 1 | 1]);
    }
    res[now] = res[now << 1] + res[now << 1 | 1];
  }
  void inline beat(int now, int x) {
    if (x <= st[now]) return;
    if (x < nd[now]) {
      tag[now] = max(tag[now], x);
      res[now] += 1ll * (x - st[now]) * sm[now];
      st[now] = x;
      return;
    }
    beat(now << 1, x);
    beat(now << 1 | 1, x);
    pu(now);
  }
  void inline pd(int now) {
    beat(now << 1, tag[now]);
    beat(now << 1 | 1, tag[now]);
  }
  void inline init(int now = 1, int nl = 0, int nr = ys - 1) {
    tag[now] = -Inf;
    if (nl == nr) {
      st[now] = in[nl];
      nd[now] = Inf;
      sm[now] = dis[nl];
      res[now] = 1ll * dis[nl] * in[nl];
      return;
    }
    int m = (nl + nr) >> 1;
    init(now << 1, nl, m);
    init(now << 1 | 1, m + 1, nr);
    pu(now);
  }
  void inline change(int l, int r, int x, int now = 1, int nl = 0,
                     int nr = ys - 1) {
    if (nl > r || nr < l) return;
    if (nl >= l && nr <= r) return beat(now, x);
    pd(now);
    int m = (nl + nr) >> 1;
    change(l, r, x, now << 1, nl, m);
    change(l, r, x, now << 1 | 1, m + 1, nr);
    pu(now);
  }
} seg;
int main() {
  scanf("%d%d%d", &n, &k, &L);
  for (int i = 1; i <= (n); i++) {
    scanf("%d%d%d", x + i, y + i, c + i);
    x[i]++;
    y[i]++;
    xls.push_back(x[i]);
    yls.push_back(y[i]);
  }
  sort((xls).begin(), (xls).end());
  xls.resize(unique((xls).begin(), (xls).end()) - xls.begin());
  xs = ((int)(xls).size());
  sort((yls).begin(), (yls).end());
  yls.resize(unique((yls).begin(), (yls).end()) - yls.begin());
  ys = ((int)(yls).size());
  for (int i = 1; i <= (n); i++) {
    x[i] = lower_bound((xls).begin(), (xls).end(), x[i]) - xls.begin();
    y[i] = lower_bound((yls).begin(), (yls).end(), y[i]) - yls.begin();
    nds[x[i]].push_back(make_pair(y[i], c[i]));
  }
  for (int i = 0; i < (ys); i++) dis[i] = yls[i] - (i ? yls[i - 1] : 0);
  int ans = 0;
  for (int i = 0; i < (xs); i++) {
    for (int j = 0; j < (ys); j++) yis[j].clear();
    for (int j = 0; j < (i + 1); j++) {
      for (int k = 0; k < (((int)(nds[j]).size())); k++) {
        int y = nds[j][k].first, c = nds[j][k].second;
        cls[c].insert(y);
        yis[y].push_back(c);
      }
    }
    multiset<int> nxts;
    for (int j = 1; j <= (k); j++) {
      nxt[j] = L + 1;
      nxts.insert(-(L + 1));
    }
    for (int j = (ys - 1); ((-1) > 0 ? j <= (0) : j >= (0)); j += (-1)) {
      for (int k = 0; k < (((int)(yis[j]).size())); k++) {
        nxts.erase(nxts.find(-nxt[yis[j][k]]));
        nxt[yis[j][k]] = j;
        nxts.insert(-nxt[yis[j][k]]);
      }
      in[j] = -*nxts.begin();
      if (in[j] != L + 1) in[j] = yls[in[j]];
    }
    seg.init();
    int xr = (i == xs - 1 ? L + 1 - xls[i] : xls[i + 1] - xls[i]);
    for (int j = 0; j < (i + 1); j++) {
      int allen = 1ll * xr * (xls[j] - (j ? xls[j - 1] : 0)) % jt;
      ans = (ans + (1ll * yls.back() * (L + 1) - seg.res[1]) % jt * allen) % jt;
      for (int k = 0; k < (((int)(nds[j]).size())); k++) {
        int y = nds[j][k].first, c = nds[j][k].second;
        cls[c].erase(cls[c].find(y));
        if (!cls[c].count(y)) {
          multiset<int>::iterator it = cls[c].lower_bound(y);
          int nxt = (it == cls[c].end() ? L + 1 : yls[*it]);
          if (it == cls[c].begin()) {
            seg.change(0, y, nxt);
          } else {
            seg.change(*(--it) + 1, y, nxt);
          }
        }
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}