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 G1, typename G2 = G1, typename G3 = G1>
struct triple {
  G1 first;
  G2 second;
  G3 T;
};
const long long mod = 1e9 + 7;
long long sum(long long a, long long b) {
  a += b;
  if (a >= b) a -= mod;
  if (a < 0) a += mod;
  return a;
}
struct st {
  int n;
  set<pair<long long, long long>> s;
  long long t = 0;
  st(int _n) : n(_n) { s.insert({n, n + 1}); }
  void upd(pair<long long, long long> x) {
    t = sum(t, ((*s.begin()).first - x.first) * x.second % mod);
    s.insert(x);
  }
  void upd(long long l, long long m) {
    auto it = s.lower_bound({l, 0});
    pair<long long, long long> last = {l, 0};
    if ((*it).first > l) {
      --it;
      last.second = (*it).second;
      ++it;
    }
    if (last.second >= m || ((*it).first == l && (*it).second >= m)) return;
    vector<pair<long long, long long>> del;
    while ((*it).second < m) {
      del.push_back(*it);
      t = sum(t, ((*it).first - last.first) * (m - last.second) % mod);
      last = *it;
      ++it;
    }
    t = sum(t, ((*it).first - last.first) * (m - last.second) % mod);
    for (auto i : del) s.erase(i);
    s.insert({l, m});
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, k, l;
  cin >> n >> k >> l;
  vector<triple<long long>> v(n);
  for (auto &i : v) cin >> i.first >> i.second >> i.T, --i.T;
  sort(v.begin(), v.end(), [](triple<long long> x, triple<long long> y) {
    return x.first < y.first;
  });
  vector<multiset<long long>> t(k);
  long long ans = 0;
  long long p = 0, last = -1;
  while (p < n) {
    for (int i = 0; i < k; i++) t[i].clear();
    vector<pair<long long, long long>> w;
    for (int i = p; i < n; i++) {
      t[v[i].T].insert(v[i].second);
      w.push_back({v[i].second, v[i].T});
    }
    for (int i = 0; i < k; i++) t[i].insert(l);
    sort(w.begin(), w.end());
    multiset<long long> temp;
    vector<long long> ex(k, l + 1);
    st s(l);
    for (int i = 0; i < k; i++) temp.insert(l + 1);
    long long lp = l + 1;
    for (int i = w.size() - 1, j = i; i >= 0; i = j) {
      for (; j >= 0 && w[j].first == w[i].first; j--) {
        temp.erase(temp.find(ex[w[j].second]));
        ex[w[j].second] = w[j].first + 1;
        temp.insert(w[j].first + 1);
      }
      if (*temp.rbegin() != lp) {
        s.upd({w[i].first + 1, lp});
        lp = *temp.rbegin();
      }
    }
    if ((*s.s.begin()).first != 0) s.upd({0, lp});
    long long lx = l;
    for (int i = n - 1, j = i; i >= p; i = j) {
      ans = sum(ans, (v[p].first - last) * (lx - v[i].first) % mod *
                         ((l * (l + 1) - s.t) % mod) % mod);
      lx = v[i].first;
      for (; j >= p && v[j].first == v[i].first; j--) {
        long long ri = v[j].second;
        t[v[j].T].erase(t[v[j].T].find(ri));
        auto it = t[v[j].T].lower_bound(ri);
        long long m = (*it) + 1;
        long long li = 0;
        if (it != t[v[j].T].begin()) {
          --it;
          li = *it + 1;
        }
        s.upd(li, m);
      }
    }
    last = v[p].first;
    int id = p;
    for (; id < n && v[id].first == v[p].first; ++id)
      ;
    p = id;
  }
  cout << ans << '\n';
  return 0;
}