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>
#pragma GCC optimize(3)
using namespace std;
const int N = 6005, mod = 1000000007;
int n, k, l, ln, lm, mn[N << 2], cm[N << 2], sz[N << 2], ans[N << 2],
    tag[N << 2], b[N], ls[N], sum;
struct node {
  int x, y, c;
  bool operator<(const node k) const { return x == k.x ? y < k.y : x < k.x; }
} a[N];
vector<int> vx, vy, xd[N], yd[N];
multiset<int> s[N], st;
void pushup(int k) {
  ans[k] = (ans[k << 1] + ans[k << 1 | 1]) % mod;
  if (mn[k << 1] < mn[k << 1 | 1]) {
    mn[k] = mn[k << 1];
    sz[k] = sz[k << 1];
    cm[k] = min(cm[k << 1], mn[k << 1 | 1]);
  } else if (mn[k << 1] > mn[k << 1 | 1]) {
    mn[k] = mn[k << 1 | 1];
    sz[k] = sz[k << 1 | 1];
    cm[k] = min(mn[k << 1], cm[k << 1 | 1]);
  } else {
    mn[k] = mn[k << 1];
    sz[k] = sz[k << 1] + sz[k << 1 | 1];
    cm[k] = min(cm[k << 1], cm[k << 1 | 1]);
  }
}
void change(int k, int v) {
  if (v <= mn[k]) return;
  if (v < cm[k]) {
    ans[k] = (ans[k] + 1ll * (v - mn[k]) * sz[k] % mod) % mod;
    tag[k] = max(tag[k], v);
    mn[k] = v;
    return;
  }
  change(k << 1, v);
  change(k << 1 | 1, v);
  pushup(k);
}
void pushdown(int k) {
  change(k << 1, tag[k]);
  change(k << 1 | 1, tag[k]);
}
void build(int k, int l, int r) {
  tag[k] = 0;
  if (l == r) {
    mn[k] = vy[b[l]];
    cm[k] = 2e9;
    sz[k] = (vy[l + 1] - vy[l]) % mod;
    ans[k] = 1ll * mn[k] * sz[k] % mod;
    return;
  }
  int mid = l + r >> 1;
  build(k << 1, l, mid);
  build(k << 1 | 1, mid + 1, r);
  pushup(k);
}
void update(int k, int l, int r, int a, int b, int v) {
  if (l == a && r == b) {
    change(k, v);
    return;
  }
  pushdown(k);
  int mid = l + r >> 1;
  if (b <= mid)
    update(k << 1, l, mid, a, b, v);
  else if (a > mid)
    update(k << 1 | 1, mid + 1, r, a, b, v);
  else
    update(k << 1, l, mid, a, mid, v),
        update(k << 1 | 1, mid + 1, r, mid + 1, b, v);
  pushup(k);
}
void del(int p) {
  int c = a[p].c, y = a[p].y;
  s[c].erase(s[c].find(y));
  if (s[c].count(y)) return;
  auto it = s[c].lower_bound(y);
  int ri = *it, le = *(--it) + 1;
  update(1, 1, lm, le, y, vy[ri]);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k >> l;
  vx.push_back(l + 1), vx.push_back(1), vx.push_back(0);
  vy.push_back(l + 1), vy.push_back(1), vy.push_back(0);
  for (int i = 1; i <= n; i++) {
    cin >> a[i].x >> a[i].y >> a[i].c;
    a[i].x++;
    a[i].y++;
    vx.push_back(a[i].x);
    vx.push_back(a[i].x + 1);
    vy.push_back(a[i].y);
    vy.push_back(a[i].y + 1);
  }
  sort(vx.begin(), vx.end());
  vx.erase(unique(vx.begin(), vx.end()), vx.end());
  sort(vy.begin(), vy.end());
  vy.erase(unique(vy.begin(), vy.end()), vy.end());
  ln = vx.size() - 2, lm = vy.size() - 2;
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    a[i].x = lower_bound(vx.begin(), vx.end(), a[i].x) - vx.begin();
    a[i].y = lower_bound(vy.begin(), vy.end(), a[i].y) - vy.begin();
    xd[a[i].x].push_back(i);
    yd[a[i].y].push_back(i);
  }
  for (int i = 1; i <= ln; i++) {
    st.clear();
    for (int j = 1; j <= k; j++) {
      s[j].clear();
      s[j].insert(0);
      s[j].insert(lm + 1);
      ls[j] = lm + 1;
      st.insert(ls[j]);
    }
    for (int j = lm; j >= 1; j--) {
      for (auto p : yd[j]) {
        if (a[p].x > i) continue;
        int c = a[p].c;
        s[c].insert(a[p].y);
        if (ls[c] != j) {
          st.erase(st.find(ls[c]));
          ls[c] = j;
          st.insert(ls[c]);
        }
      }
      b[j] = *(--st.end());
    }
    build(1, 1, lm);
    for (int j = 1; j <= i; j++) {
      sum = (sum + (1ll * l * (l + 1) % mod + mod - ans[1] % mod) % mod *
                       (vx[i + 1] - vx[i]) % mod * (vx[j + 1] - vx[j]) % mod) %
            mod;
      for (auto p : xd[j]) del(p);
    }
  }
  cout << sum << endl;
  return 0;
}