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 MAXN = 2e3 + 5;
const int MAXD = 2e3 + 5;
const int mod = 1e9 + 7;
inline void add_mod(int &a, int b) {
  if ((a += b) >= mod) a -= mod;
}
struct Solver {
  set<pair<int, int> > t;
  int res;
  Solver(void) : res(0) {}
  inline int chose2(int l, int r) {
    return l > r ? 0 : ((long long)(r - l + 1) * (r - l + 1 + 1) / 2) % mod;
  }
  inline void update(set<pair<int, int> >::iterator it, int k) {
    set<pair<int, int> >::iterator pre = it, nxt = it;
    ++nxt;
    if (it != t.begin())
      --pre, res = (res - (long long)k * chose2(it->first, -pre->second)) % mod;
    if (nxt != t.end())
      res = (res - (long long)k * chose2(nxt->first, -it->second)) % mod;
    if (it != t.begin() && nxt != t.end())
      res = (res + (long long)k * chose2(nxt->first, -pre->second)) % mod;
    res = (res + (long long)k * chose2(it->first, -it->second)) % mod;
    if (res < 0) res += mod;
  }
  inline int query(void) { return res; }
  inline void erase(set<pair<int, int> >::iterator it) {
    update(it, -1);
    t.erase(it);
  }
  inline void insert(int l, int r) {
    if (l > r) return;
    pair<int, int> cur = make_pair(l, -r);
    set<pair<int, int> >::iterator it = t.lower_bound(cur);
    while (it != t.end() && -it->second <= r)
      erase(it), it = t.lower_bound(cur);
    if (it != t.begin() && -((--it)->second) >= r) return;
    update(t.insert(cur).first, 1);
  }
};
struct Node {
  int x, y, clr;
} p[MAXN];
inline bool cmp_x(const Node &p, const Node &q) { return p.x < q.x; }
int main(void) {
  int n, d, L;
  scanf("%d%d%d", &n, &d, &L);
  for (int i = 1; i <= n; ++i)
    scanf("%d%d%d", &p[i].x, &p[i].y, &p[i].clr), ++p[i].x, ++p[i].y;
  sort(p + 1, p + n + 1, cmp_x);
  p[n + 1].x = L + 1;
  long long tot = ((long long)L * (L + 1) / 2) % mod;
  long long ans = 0;
  for (int k = 1; k <= n; ++k)
    if (p[k].x != p[k + 1].x) {
      static multiset<int> t[MAXD];
      for (int i = 1; i <= d; ++i)
        t[i].clear(), t[i].insert(0), t[i].insert(L + 1);
      for (int i = 1; i <= k; ++i) t[p[i].clr].insert(p[i].y);
      Solver solver;
      bool flag = 1;
      for (int i = 1; i <= d; ++i) {
        if ((int)t[i].size() <= 2) {
          flag = 0;
          break;
        }
        multiset<int>::iterator it = t[i].begin();
        while (*it <= L) {
          int l = *it + 1;
          ++it;
          solver.insert(l, *it - 1);
        }
      }
      if (!flag) continue;
      for (int i = 1; i <= k; ++i) {
        if (p[i].x != p[i - 1].x) {
          long long res = (tot + mod - solver.query()) % mod;
          if (!res) break;
          ans = (ans +
                 res * (p[k + 1].x - p[k].x) % mod * (p[i].x - p[i - 1].x)) %
                mod;
        }
        multiset<int> &tt = t[p[i].clr];
        multiset<int>::iterator it = tt.lower_bound(p[i].y), pre = it, nxt = it;
        --pre;
        ++nxt;
        tt.erase(it);
        solver.insert(*pre + 1, *nxt - 1);
      }
    }
  printf("%lld\n", ans);
  return 0;
}