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 N = (int)6005, mod = (int)1e9 + 7;
int len;
int seg[N << 2], mx[N << 2], sum[N << 2], ch[N << 2], px[N], py[N], pc[N], o[N],
    sx[N], sy[N], sc[N];
set<pair<int, int>> col[N];
vector<int> allx, ally;
int get_pos(int first) {
  return lower_bound((ally).begin(), (ally).end(), first) - ally.begin();
}
void build(int v = 1, int b = 0, int e = (int)ally.size() - 1) {
  ch[v] = -1;
  mx[v] = 0;
  if (b + 1 == e) {
    seg[v] = (ally[e] - ally[b]) * (long long)(len - 0) % mod;
    return;
  }
  int m = b + e >> 1, l = v << 1, r = l | 1;
  build(l, b, m);
  build(r, m, e);
  seg[v] = (seg[l] + seg[r]) % mod;
}
void apply(int v, int b, int e, int first) {
  assert(mx[v] != -1);
  if (mx[v] >= first) return;
  seg[v] = (len - first) * (long long)(ally[e] - ally[b]) % mod;
  mx[v] = first;
  ch[v] = first;
}
void push(int v, int b, int e) {
  if (ch[v] == -1) return;
  int m = b + e >> 1, l = v << 1, r = l | 1;
  apply(l, b, m, ch[v]);
  apply(r, m, e, ch[v]);
  ch[v] = -1;
}
void update(int i, int j, int first, int v = 1, int b = 0,
            int e = (int)ally.size() - 1) {
  if (i >= e || b >= j) return;
  if (i <= b && e <= j && mx[v] != -1) {
    apply(v, b, e, first);
    return;
  }
  int m = b + e >> 1, l = v << 1, r = l | 1;
  push(v, b, e);
  update(i, j, first, l, b, m);
  update(i, j, first, r, m, e);
  seg[v] = (seg[l] + seg[r]) % mod;
  mx[v] = (mx[l] == mx[r] ? mx[l] : -1);
}
int cmp(int first, int second) { return px[first] < px[second]; }
int main() {
  int n, k;
  cin >> n >> k >> len;
  for (int i = 0; i < n; ++i) {
    cin >> px[i] >> py[i] >> pc[i];
    allx.push_back(px[i]);
    ally.push_back(py[i]);
    ally.push_back(py[i] + 1);
    o[i] = i;
    --pc[i];
  }
  o[n] = n;
  sort(o, o + n, cmp);
  allx.push_back(0);
  allx.push_back(len);
  ally.push_back(0);
  ally.push_back(len);
  sort((allx).begin(), (allx).end());
  sort((ally).begin(), (ally).end());
  allx.resize(unique((allx).begin(), (allx).end()) - allx.begin());
  ally.resize(unique((ally).begin(), (ally).end()) - ally.begin());
  sx[n] = len;
  for (int i = 0; i < n; ++i)
    sx[i] = px[o[i]], sy[i] = py[o[i]], sc[i] = pc[o[i]];
  int res = 0;
  for (int l = 0; l < n; ++l) {
    int s = (sx[l] - (l == 0 ? -1 : sx[l - 1]));
    if (!s) continue;
    for (int i = 0; i < k; ++i) {
      col[i].clear();
      col[i].insert(make_pair(-1, -1));
      col[i].insert(make_pair(len, -1));
    }
    for (int cur = l; cur < n; ++cur) {
      col[sc[cur]].insert(make_pair(sy[cur], cur));
    }
    build();
    for (int color = 0; color < k; ++color) {
      int lasty = -1;
      for (auto it : col[color]) {
        int cury = it.first;
        update(get_pos(lasty + 1), get_pos(cury + 1), cury);
        lasty = cury;
      }
    }
    for (int r = n; r >= l + 1; --r) {
      int mult = (long long)(sx[l] - (l == 0 ? -1 : sx[l - 1])) *
                 (sx[r] - sx[r - 1]) % mod;
      res = (res + (long long)mult * seg[1]) % mod;
      int id = r - 1;
      auto it = col[sc[id]].lower_bound(make_pair(sy[id], id));
      --it;
      col[sc[id]].erase(make_pair(sy[id], id));
      auto nx = it;
      ++nx;
      update(get_pos((it->first) + 1), get_pos((nx->first) + 1), nx->first);
    }
  }
  cout << res << endl;
}