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;
template <typename T>
inline void qr(T &x) {
  x = 0;
  int f = 0;
  char s = getchar();
  while (s < '0' || '9' < s) f |= s == '-', s = getchar();
  while ('0' <= s && s <= '9') x = x * 10 + s - 48, s = getchar();
  x = f ? -x : x;
}
int cc = 0, buf[31];
template <typename T>
inline void qw(T x) {
  if (x < 0) putchar('-'), x = -x;
  do {
    buf[++cc] = int(x % 10);
    x /= 10;
  } while (x);
  while (cc) putchar(buf[cc--] + '0');
  puts("");
}
int ad(int x, int y) {
  return (x + y) >= 1000000007 ? x + y - 1000000007 : x + y;
}
int mu(int x, int y) { return 1ll * x * y % 1000000007; }
int de(int x, int y) { return (x - y) < 0 ? x - y + 1000000007 : x - y; }
const int N = 2e3 + 10;
struct LS {
  int m, s[N];
  void ins(int x) { s[++m] = x; }
  int work() {
    sort(s + 1, s + m + 1);
    m = unique(s + 1, s + m + 1) - s - 1;
    return m;
  }
  int id(int x) { return lower_bound(s + 1, s + m + 1, x) - s; }
  int rl(int i) { return s[i]; }
} X, Y;
namespace SGT {
struct node {
  int l, r, c, mx, lz;
} t[N << 2];
void build(int p, int l, int r) {
  t[p] = (node){l, r, 0, 0, 0};
  if (l < r)
    build(p << 1, l, (t[p].l + t[p].r) / 2),
        build(p << 1 | 1, (t[p].l + t[p].r) / 2 + 1, r);
}
void work(int p, int k) {
  t[p].c = mu(Y.rl(t[p].r) - Y.rl(t[p].l - 1), k);
  t[p].mx = t[p].lz = k;
}
void pushdown(int p) {
  if (t[p].lz) work(p << 1, t[p].lz), work(p << 1 | 1, t[p].lz), t[p].lz = 0;
}
bool change(int p, int l, int r, int k) {
  if (l <= t[p].l && t[p].r <= r) {
    if (t[p].mx < k) {
      work(p, k);
      return 0;
    } else {
      if (t[p].l == t[p].r) return 1;
      pushdown(p);
      if (!change(p << 1, l, r, k)) change(p << 1 | 1, l, r, k);
      t[p].c = ad(t[p << 1].c, t[p << 1 | 1].c);
      t[p].mx = max(t[p << 1].mx, t[p << 1 | 1].mx);
      return 1;
    }
  }
  pushdown(p);
  bool bk = 0;
  if (l <= (t[p].l + t[p].r) / 2) bk = change(p << 1, l, r, k);
  if ((t[p].l + t[p].r) / 2 < r && !bk) bk = change(p << 1 | 1, l, r, k);
  t[p].c = ad(t[p << 1].c, t[p << 1 | 1].c);
  t[p].mx = max(t[p << 1].mx, t[p << 1 | 1].mx);
  return bk;
}
void dfs(int p) {
  if (t[p].l == t[p].r) {
    printf("%d ", t[p].mx);
    return;
  }
  pushdown(p);
  dfs(p << 1);
  dfs(p << 1 | 1);
}
int calc() { return t[1].c; }
}  // namespace SGT
int n, m, L, c1, c2;
struct Point {
  int x, y, z;
} a[N];
vector<int> h[N];
multiset<int> c[N];
multiset<int>::iterator it;
int main() {
  qr(n), qr(m), qr(L);
  for (int i = 1; i <= n; i++) {
    qr(a[i].x), qr(a[i].y), qr(a[i].z);
    a[i].x++, a[i].y++;
    X.ins(a[i].x), Y.ins(a[i].y);
  }
  X.ins(L + 1);
  Y.ins(L + 1);
  c1 = X.work() - 1;
  c2 = Y.work();
  for (int i = 1; i <= n; i++) {
    a[i].x = X.id(a[i].x);
    a[i].y = Y.id(a[i].y);
    h[a[i].x].push_back(i);
  }
  int ans = 0;
  for (int i = 1; i <= c1; i++) {
    SGT::build(1, 1, c2);
    for (int j = 1; j <= m; j++) c[j].clear(), c[j].insert(0), c[j].insert(c2);
    for (int j = i; j <= c1; j++)
      for (int k : h[j]) c[a[k].z].insert(a[k].y);
    int mn = c2;
    for (int j = 1; j <= m; j++) mn = min(mn, *(--(--c[j].end())));
    if (!mn) break;
    for (int j = 1; j <= m; j++) {
      int last = 0;
      for (it = (++c[j].begin()); it != c[j].end(); it++) {
        if (last < (*it))
          SGT::change(1, last + 1, (*it), Y.rl(*it)), last = (*it);
      }
    }
    int ret = 0;
    for (int j = c1; j >= i; j--) {
      ret = ad(ret, mu(X.rl(j + 1) - X.rl(j),
                       de(mu(L + 1, L), SGT::calc() - L - 1)));
      for (int k : h[j]) {
        it = c[a[k].z].lower_bound(a[k].y);
        c[a[k].z].erase(it);
        it = c[a[k].z].lower_bound(a[k].y);
        if ((*it) == a[k].y)
          continue;
        else {
          int rht = (*it);
          it--;
          int lft = (*it);
          SGT::change(1, lft + 1, a[k].y, Y.rl(rht));
        }
      }
    }
    ans = ad(ans, mu(ret, X.rl(i) - X.rl(i - 1)));
  }
  qw(ans);
  return 0;
}