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;
long long read() {
  long long a = 0;
  char c = getchar();
  while (c > '9' || c < '0') c = getchar();
  while ('0' <= c && c <= '9') {
    a = a * 10 + c - 48;
    c = getchar();
  }
  return a;
}
struct data {
  long long x, y, c;
  data(long long X = 0, long long Y = 0, long long C = 0) {
    x = X;
    y = Y;
    c = C;
  }
} w[2005], e[2005];
long long n, k, L;
bool cmp(data a, data b) { return a.x < b.x; };
bool cmp2(data a, data b) { return a.y < b.y; }
long long nxt[2005], f[2005];
multiset<long long> Set[2005];
long long sum[2005 << 2], Max[2005 << 2], tag[2005 << 2];
void pushup(long long x) {
  sum[x] = (sum[(x << 1)] + sum[(x << 1 | 1)]) % 1000000007;
  assert(Max[(x << 1)] <= Max[(x << 1 | 1)]);
  Max[x] = Max[(x << 1 | 1)];
}
void build(long long x, long long l, long long r) {
  tag[x] = 0;
  if (l == r) {
    sum[x] = f[l] * (e[l].y - e[l - 1].y) % 1000000007;
    Max[x] = f[l];
    return;
  }
  build((x << 1), l, ((l + r) >> 1));
  build((x << 1 | 1), ((l + r) >> 1) + 1, r);
  pushup(x);
}
void ptag(long long x, long long l, long long r, long long v) {
  assert(Max[x] <= v);
  sum[x] = v * (e[r].y - e[l - 1].y) % 1000000007;
  tag[x] = Max[x] = v;
}
void pushdown(long long x, long long l, long long r) {
  if (tag[x]) {
    ptag((x << 1), l, ((l + r) >> 1), tag[x]);
    ptag((x << 1 | 1), ((l + r) >> 1) + 1, r, tag[x]);
    tag[x] = 0;
  }
}
void chkmax(long long x, long long l, long long r, long long b, long long e,
            long long v) {
  if (r < b || l > e) return;
  if (l == r && Max[x] > v) return;
  if (Max[x] <= v && b <= l && r <= e) {
    ptag(x, l, r, v);
    return;
  }
  bool flag = (v > Max[(x << 1)]);
  pushdown(x, l, r);
  chkmax((x << 1), l, ((l + r) >> 1), b, e, v);
  if (flag) chkmax((x << 1 | 1), ((l + r) >> 1) + 1, r, b, e, v);
  pushup(x);
}
signed main() {
  n = read();
  k = read();
  L = read();
  for (long long i = 1; i <= n; ++i) {
    w[i].x = read() + 1;
    w[i].y = read() + 1;
    w[i].c = read();
    e[i] = w[i];
  }
  sort(w + 1, w + 1 + n, cmp);
  sort(e + 1, e + 1 + n, cmp2);
  e[n + 1].y = L + 1;
  w[n + 1].x = w[n + 2].x = L + 1;
  w[n + 1].y = L + 1;
  long long ans = 0;
  for (long long i = n; i; --i) {
    long long tmp = (w[i].x - w[i - 1].x);
    if (!tmp) continue;
    multiset<long long> S;
    S.clear();
    for (long long i = 1; i <= k; ++i) {
      S.insert(L + 1), nxt[i] = L + 1;
      Set[i].clear();
      Set[i].insert(L + 1);
      Set[i].insert(0);
    }
    for (long long j = n; j; --j) {
      if (e[j].x >= w[i].x) {
        S.erase(S.find(nxt[e[j].c]));
        nxt[e[j].c] = e[j].y;
        S.insert(nxt[e[j].c]);
        Set[e[j].c].insert(e[j].y);
      }
      f[j] = (*(--S.end()));
    }
    build(1, 1, n);
    for (long long j = n + 1; j > i; --j) {
      if (w[j].c) {
        assert(Set[w[j].c].find(w[j].y) != Set[w[j].c].end());
        Set[w[j].c].erase(Set[w[j].c].find(w[j].y));
        multiset<long long>::iterator it = --Set[w[j].c].upper_bound(w[j].y),
                                      ir = it;
        ++ir;
        long long ll = lower_bound(e, e + 1 + n, data(0, *it, 0), cmp2) - e;
        if (ll) assert(e[ll].y != e[ll - 1].y);
        chkmax(1, 1, n, ll + 1, n, *ir);
      }
      long long res = ((L + 1) * e[n].y - sum[1] + 1000000007) % 1000000007;
      ans =
          (ans + (res * tmp % 1000000007 * (w[j].x - w[j - 1].x))) % 1000000007;
    }
  }
  printf("%lld\n", ans);
  return 0;
}