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 mod = 1000000007;
pair<pair<int, int>, int> a[2010];
multiset<int> all[2010];
long long tot;
int L;
set<pair<int, int> > S;
int get_pre(multiset<int> &s, int x) {
  multiset<int>::iterator it = s.lower_bound(x);
  return it == s.begin() ? -1 : *(--it);
}
int get_suc(multiset<int> &s, int x) {
  multiset<int>::iterator it = s.lower_bound(x);
  return it == s.end() ? L : *it;
}
void Clear() { tot = 0, S.clear(); }
pair<int, int> get_pre(set<pair<int, int> > &s,
                       set<pair<int, int> >::iterator it) {
  if (it == s.begin()) return make_pair(-1, 0);
  return *(--it);
}
pair<int, int> get_suc(set<pair<int, int> > &s,
                       set<pair<int, int> >::iterator it) {
  ++it;
  if (it == s.end()) return make_pair(-1, 0);
  return *it;
}
long long calc(int l, int r) {
  if (l >= r) return 0;
  return 1ll * (r - l) * (r - l + 1) / 2;
}
void Change(set<pair<int, int> >::iterator it, int flag) {
  pair<int, int> pre = get_pre(S, it), suc = get_suc(S, it);
  tot -= calc(it->first, -it->second) * flag;
  if (~pre.first) tot += calc(it->first, -pre.second) * flag;
  if (~suc.first) tot += calc(suc.first, -it->second) * flag;
  if (~pre.first && ~suc.first) tot -= calc(suc.first, -pre.second) * flag;
}
void Add(int l, int r) {
  if (l >= r) return;
  set<pair<int, int> >::iterator it = S.lower_bound(make_pair(l, -r));
  while (it != S.end() && -it->second <= r) Change(it, 1), it = S.erase(it);
  if (it == S.begin()) {
    S.insert(make_pair(l, -r));
    it = S.lower_bound(make_pair(l, -r));
    Change(it, -1);
    return;
  }
  it--;
  if (-it->second >= r) return;
  S.insert(make_pair(l, -r));
  it = S.lower_bound(make_pair(l, -r));
  Change(it, -1);
}
int main() {
  int n, k;
  scanf("%d%d%d", &n, &k, &L);
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &a[i].first.first, &a[i].first.second, &a[i].second);
  }
  sort(a, a + n);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (i && a[i].first.first == a[i - 1].first.first) continue;
    int M1 = a[i].first.first - (i ? a[i - 1].first.first : -1);
    for (int j = i; j < n; j++) {
      int y = a[j].first.second, k = a[j].second;
      all[k].insert(y);
    }
    Clear();
    for (int j = 1; j <= k; j++) {
      int lst = -1;
      for (auto x : all[j]) {
        Add(lst + 1, x);
        lst = x;
      }
      Add(lst + 1, L);
    }
    for (int j = n - 1; j >= i; j--) {
      int y = a[j].first.second, c = a[j].second;
      int M2 = (j + 1 == n ? L : a[j + 1].first.first) - a[j].first.first;
      long long delta = (1ll * L * (L + 1) / 2 - tot) % mod;
      delta = delta * M1 % mod * M2 % mod;
      ans = (ans + delta) % mod;
      all[c].erase(all[c].find(y));
      if (!all[c].count(y)) {
        int pre = get_pre(all[c], y), suc = get_suc(all[c], y);
        Add(pre + 1, suc);
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}