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 long long maxn = 2e3 + 10;
const long long Mod = 1e9 + 7;
long long n, N1, N2, k, L, lst, p1[maxn], p2[maxn], ans;
struct node {
  long long x, y, c;
} a[maxn];
struct Node {
  long long len, sum, lazy, val;
} Tree[maxn << 2];
vector<pair<long long, long long> > p, b[maxn];
multiset<long long> Col[maxn];
inline void PushTag(long long root, long long val) {
  Tree[root].sum = val * Tree[root].len;
  Tree[root].lazy = Tree[root].val = val;
}
inline void PushUp(long long root) {
  Tree[root].sum = Tree[root << 1].sum + Tree[root << 1 | 1].sum;
  Tree[root].val = Tree[root << 1].val;
}
inline void PushDown(long long root) {
  if (!Tree[root].lazy) return;
  PushTag(root << 1, Tree[root].lazy);
  PushTag(root << 1 | 1, Tree[root].lazy);
  Tree[root].lazy = 0;
}
inline void Build(long long root, long long l, long long r) {
  Tree[root].len = p1[r] - p1[l - 1];
  Tree[root].sum = Tree[root].len * (L + 1);
  Tree[root].lazy = 0;
  if (l == r) {
    Tree[root].val = Tree[root].sum;
    return;
  }
  long long Mid = l + r >> 1;
  Build(root << 1, l, Mid);
  Build(root << 1 | 1, Mid + 1, r);
  PushUp(root);
}
inline void Modify(long long root, long long l, long long r, long long L,
                   long long R, long long val) {
  if (L > R) return;
  if (L <= l && r <= R) {
    PushTag(root, val);
    return;
  }
  long long Mid = l + r >> 1;
  PushDown(root);
  if (L <= Mid) Modify(root << 1, l, Mid, L, R, val);
  if (Mid < R) Modify(root << 1 | 1, Mid + 1, r, L, R, val);
  PushUp(root);
}
inline long long Query(long long root, long long l, long long r, long long L,
                       long long R) {
  if (L <= l && r <= R) return Tree[root].sum;
  long long Mid = l + r >> 1, ret = 0;
  PushDown(root);
  if (L <= Mid) ret += Query(root << 1, l, Mid, L, R);
  if (Mid < R) ret += Query(root << 1 | 1, Mid + 1, r, L, R);
  return ret;
}
inline long long Find(long long root, long long l, long long r, long long val) {
  if (l == r) return Tree[root].val <= val ? l : 0;
  long long Mid = l + r >> 1;
  PushDown(root);
  if (Tree[root << 1 | 1].val > val) return Find(root << 1, l, Mid, val);
  return Find(root << 1 | 1, Mid + 1, r, val);
}
signed main() {
  scanf("%lld%lld%lld", &n, &k, &L);
  for (long long i = (1), _end_ = (n); i <= _end_; ++i) {
    scanf("%lld%lld%lld", &a[i].x, &a[i].y, &a[i].c);
    ++a[i].x;
    ++a[i].y;
  }
  sort(a + 1, a + n + 1, [](node &a, node &b) { return a.x < b.x; });
  lst = 0;
  for (long long i = (1), _end_ = (n); i <= _end_; ++i)
    if (a[i].x != lst) {
      lst = p1[++N1] = a[i].x;
      a[i].x = N1;
    } else
      a[i].x = N1;
  sort(a + 1, a + n + 1, [](node &a, node &b) { return a.y < b.y; });
  lst = 0;
  for (long long i = (1), _end_ = (n); i <= _end_; ++i)
    if (a[i].y != lst) {
      lst = p2[++N2] = a[i].y;
      a[i].y = N2;
    } else
      a[i].y = N2;
  for (long long i = (1), _end_ = (n); i <= _end_; ++i)
    b[a[i].y].push_back(pair<long long, long long>(a[i].x, a[i].c));
  for (long long o = (1), _end_ = (N2); o <= _end_; ++o)
    sort(b[o].begin(), b[o].end());
  p1[N1 + 1] = p2[N2 + 1] = L + 1;
  for (long long i = (1), _end_ = (N2); i <= _end_; ++i) {
    p.clear();
    for (long long o = (1), _end_ = (k); o <= _end_; ++o) {
      Col[o].clear();
      Col[o].insert(0);
    }
    Build(1, 1, N1);
    for (long long k = (1), _end_ = (n); k <= _end_; ++k)
      if (a[k].y >= i) p.push_back(pair<long long, long long>(a[k].x, a[k].c));
    sort(p.begin(), p.end());
    for (auto k : p) {
      auto it = --Col[k.second].end();
      Modify(1, 1, N1, *it + 1, k.first, p1[k.first]);
      Col[k.second].insert(k.first);
    }
    for (long long o = (1), _end_ = (k); o <= _end_; ++o) {
      auto it = --Col[o].end();
      Modify(1, 1, N1, *it + 1, N1, L + 1);
      Col[o].insert(N1 + 1);
    }
    long long ret = ((L + 1) * p1[N1] - Tree[1].sum) % Mod;
    ret = ret * (p2[i] - p2[i - 1]) % Mod;
    ret = ret * (p2[N2 + 1] - p2[N2]) % Mod;
    ans = (ans + ret) % Mod;
    for (long long j = N2 - 1; j >= i; --j) {
      for (auto it : b[j + 1]) {
        auto pos = Col[it.second].lower_bound(it.first);
        auto l = pos, r = pos;
        --l;
        ++r;
        Modify(1, 1, N1, *l + 1, Find(1, 1, N1, p1[*r]), p1[*r]);
        Col[it.second].erase(pos);
      }
      ret = ((L + 1) * p1[N1] - Tree[1].sum) % Mod;
      ret = ret * (p2[i] - p2[i - 1]) % Mod;
      ret = ret * (p2[j + 1] - p2[j]) % Mod;
      ans = (ans + ret) % Mod;
    }
  }
  printf("%lld\n", (ans + Mod) % Mod);
  return 0;
}