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 = 2e3 + 5, mod = 1e9 + 7;
struct Segment_Tree_Beats {
  int mx, cmx, sx, sum;
  void add(int d) {
    mx = (mx + d);
    sum = (sum + 1ll * cmx * d % mod < 0 ? sum + 1ll * cmx * d % mod + mod
                                         : sum + 1ll * cmx * d % mod);
  }
} tr[N << 2];
void pushup(int p) {
  tr[p].mx = max(tr[p << 1].mx, tr[p << 1 | 1].mx);
  tr[p].sx = max(
      (tr[p].mx == tr[p << 1].mx) ? tr[p << 1].sx : tr[p << 1].mx,
      (tr[p].mx == tr[p << 1 | 1].mx) ? tr[p << 1 | 1].sx : tr[p << 1 | 1].mx);
  tr[p].cmx = (tr[p << 1].mx == tr[p].mx) * tr[p << 1].cmx +
              (tr[p << 1 | 1].mx == tr[p].mx) * tr[p << 1 | 1].cmx;
  tr[p].sum = (tr[p << 1].sum + tr[p << 1 | 1].sum >= mod
                   ? tr[p << 1].sum + tr[p << 1 | 1].sum - mod
                   : tr[p << 1].sum + tr[p << 1 | 1].sum);
}
void pushdown(int p) {
  if (tr[p].mx < tr[p << 1].mx) tr[p << 1].add(tr[p].mx - tr[p << 1].mx);
  if (tr[p].mx < tr[p << 1 | 1].mx)
    tr[p << 1 | 1].add(tr[p].mx - tr[p << 1 | 1].mx);
}
void Min(int p, int l, int r, int d) {
  if (tr[p].mx <= d) return;
  if (tr[p].sx < d && d <= tr[p].mx) return tr[p].add(d - tr[p].mx);
  int mid = (l + r) >> 1;
  pushdown(p);
  Min(p << 1, l, mid, d);
  Min(p << 1 | 1, mid + 1, r, d);
  pushup(p);
}
void upt(int p, int l, int r, int ql, int qr, int d) {
  if (ql <= l && r <= qr) return Min(p, l, r, d);
  pushdown(p);
  int mid = (l + r) >> 1;
  if (ql <= mid) upt(p << 1, l, mid, ql, qr, d);
  if (mid + 1 <= qr) upt(p << 1 | 1, mid + 1, r, ql, qr, d);
  pushup(p);
}
int n, K, L, zyk[N], bx[N], by[N];
int cnt[N], las[N];
int lenx, leny;
map<int, int> mp[N];
void build(int p, int l, int r) {
  if (l == r) {
    tr[p].mx = bx[zyk[l]];
    tr[p].sx = -1;
    tr[p].cmx = bx[l + 1] - bx[l];
    tr[p].sum = 1ll * bx[zyk[l]] * (bx[l + 1] - bx[l]) % mod;
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  pushup(p);
}
struct point {
  int x, y, col;
} a[N], b[N];
int solve(int bl) {
  if (bl > n) return 0;
  int m = 0;
  for (int i = bl; i <= n; ++i) b[++m] = a[i];
  sort(b + 1, b + m + 1, [&](point a, point b) { return a.x < b.x; });
  memset(las, 0, sizeof(las));
  memset(cnt, 0, sizeof(cnt));
  memset(zyk, 0, sizeof(zyk));
  for (int i = 1; i <= K; ++i) mp[i].clear(), ++mp[i][0];
  for (int i = 1; i <= m; ++i) mp[b[i].col][b[i].x]++;
  for (int i = 1, o = 1, j = 1, Cnt = 0; i <= lenx; ++i) {
    while (j <= m && b[j].x == i) {
      if (las[b[j].col])
        cnt[las[b[j].col]]--;
      else
        Cnt++;
      cnt[las[b[j].col] = i]++;
      ++j;
    }
    if (Cnt == K) {
      while (cnt[o] == 0) ++o;
      zyk[i] = o;
    }
  }
  build(1, 1, lenx);
  sort(b + 1, b + m + 1, [&](point a, point b) { return a.y < b.y; });
  int ans = 0, R, col, x;
  for (int i = leny, j = m; i >= 1; --i) {
    ans += 1ll * tr[1].sum * (by[i + 1] - by[i]) % mod;
    ans = (ans >= mod ? ans - mod : ans);
    while (j >= 1 && b[j].y == i) {
      col = b[j].col;
      x = b[j].x;
      mp[col][x]--;
      if (mp[col][x] == 0) {
        mp[col].erase(x);
        auto it = mp[col].lower_bound(x);
        R = (it == mp[col].end()) ? lenx : ((it->first) - 1);
        --it;
        upt(1, 1, lenx, x, R, bx[it->first]);
      }
      j--;
    }
  }
  return ans;
}
signed main() {
  cin >> n >> K >> L;
  for (int i = 1; i <= n; ++i)
    cin >> a[i].x >> a[i].y >> a[i].col, a[i].x++, a[i].y++,
        bx[++lenx] = a[i].x, by[++leny] = a[i].y;
  bx[++lenx] = L;
  by[++leny] = L;
  sort(bx + 1, bx + lenx + 1);
  lenx = unique(bx + 1, bx + lenx + 1) - bx - 1;
  sort(by + 1, by + leny + 1);
  leny = unique(by + 1, by + leny + 1) - by - 1;
  for (int i = 1; i <= n; ++i)
    a[i].x = lower_bound(bx + 1, bx + lenx + 1, a[i].x) - bx,
    a[i].y = lower_bound(by + 1, by + leny + 1, a[i].y) - by;
  bx[lenx + 1] = L + 1;
  by[leny + 1] = L + 1;
  sort(a + 1, a + n + 1, [&](point a, point b) { return a.y < b.y; });
  int ans = 0;
  for (int i = 1, j = 1; i <= leny; ++i) {
    while (j <= n && a[j].y < i) ++j;
    ans += 1ll * (by[i] - by[i - 1]) * solve(j) % mod;
    ans = (ans >= mod ? ans - mod : ans);
  }
  cout << ans;
  return 0;
}