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>
#pragma GCC optimize("O3")
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c *x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug &operator<<(const c &) {
    return *this;
  }
};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
const int mod = 1e9 + 7;
inline int add(int a, int b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
  return a;
}
inline int sub(int a, int b) {
  a -= b;
  if (a < 0) {
    a += mod;
  }
  return a;
}
inline int mul(int a, int b) { return ll(a) * b % mod; }
int N, K, X;
struct IntvCounter {
  vector<int> colors, locations;
  int sum;
  set<pii> min_intvs;
  vector<set<int>> color_locs;
  void DelIntv(int L, int R) {
    auto iter = min_intvs.find(pii(L, R));
    assert(iter != min_intvs.end());
    const int delta = locations[L] - locations[prev(iter)->first];
    if (next(iter) != min_intvs.end()) {
      sum = add(sum, mul(delta, X - locations[next(iter)->second]));
    }
    sum = sub(sum, mul(delta, X - locations[R]));
    min_intvs.erase(iter);
  }
  void AddIntv(int L, int R) {
    if (R >= ((int)(colors).size())) {
      return;
    }
    auto [iter, succ] = min_intvs.emplace(L, R);
    if (!succ) {
      return;
    }
    auto piter = prev(iter);
    if (piter->first == L) {
      min_intvs.erase(iter);
      return;
    } else if (next(iter) != min_intvs.end() && next(iter)->second <= R) {
      min_intvs.erase(iter);
      return;
    }
    const int delta = locations[L] - locations[piter->first];
    if (next(iter) != min_intvs.end()) {
      sum = sub(sum, mul(delta, X - locations[next(iter)->second]));
    }
    sum = add(sum, mul(delta, X - locations[R]));
  }
  IntvCounter(const vi &cols, const vi &locs) : colors(cols), locations(locs) {
    min_intvs.emplace(0, 0);
    colors.insert(colors.begin(), -1);
    locations.insert(locations.begin(), -1);
    debug() << "IntvCounter"
            << " ["
            << "colors"
               ": "
            << (colors) << "] "
            << " ["
            << "locations"
               ": "
            << (locations) << "] ";
    sum = 0;
    const int M = ((int)(colors).size());
    int lft = 1, rgt = 0;
    map<int, int> mp;
    vector<pii> add_intvs;
    while (lft <= M - 1) {
      while (rgt < M - 1 && ((int)(mp).size()) < K) {
        ++rgt;
        ++mp[colors[rgt]];
      }
      if (rgt == M - 1 && ((int)(mp).size()) < K) {
        break;
      }
      while (!add_intvs.empty() && add_intvs.back().second == rgt) {
        add_intvs.pop_back();
      }
      add_intvs.emplace_back(lft, rgt);
      if (--mp[colors[lft]] == 0) {
        mp.erase(colors[lft]);
      }
      ++lft;
    }
    for (auto &intv : add_intvs) {
      AddIntv(intv.first, intv.second);
    }
    color_locs.resize(K + 1);
    for (int i = 1; i < M; ++i) {
      color_locs[colors[i]].insert(i);
    }
    debug() << " ["
            << "min_intvs"
               ": "
            << (min_intvs) << "] "
            << " ["
            << "sum"
               ": "
            << (sum) << "] ";
  }
  void DelItem(int loc) {
    ++loc;
    const int col = colors[loc];
    debug() << " ["
            << "loc"
               ": "
            << (loc) << "] "
            << " ["
            << "col"
               ": "
            << (col) << "] ";
    auto &CL = color_locs[col];
    auto iter = CL.find(loc);
    assert(iter != CL.end());
    bool is_ok = iter != CL.begin();
    int from_where = iter == CL.begin() ? 1 : *prev(iter) + 1;
    int to_where =
        next(iter) == CL.end() ? ((int)(colors).size()) + 5 : *next(iter);
    CL.erase(iter);
    auto intv_iter = min_intvs.lower_bound(make_pair(from_where, -1));
    vector<pii> to_erase;
    while (intv_iter != min_intvs.end() && intv_iter->first <= loc) {
      if (intv_iter->second >= to_where) {
        break;
      }
      to_erase.push_back(*intv_iter);
      ++intv_iter;
    }
    if (to_erase.empty()) {
      return;
    }
    for (auto &elem : to_erase) {
      DelIntv(elem.first, elem.second);
    }
    if (is_ok) {
      AddIntv(from_where - 1, to_erase[0].second);
    }
    AddIntv(to_erase.back().first, to_where);
    debug() << " ["
            << "min_intvs"
               ": "
            << (min_intvs) << "] "
            << " ["
            << "sum"
               ": "
            << (sum) << "] ";
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> N >> K >> X;
  vector<tuple<int, int, int>> items(N);
  for (auto &[x, y, c] : items) {
    cin >> x >> y >> c;
  }
  sort((items).begin(), (items).end());
  for (auto &[x, y, c] : items) {
    debug() << " ["
            << "x"
               ": "
            << (x) << "] "
            << " ["
            << "y"
               ": "
            << (y) << "] "
            << " ["
            << "c"
               ": "
            << (c) << "] ";
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    const int diff_left =
        get<0>(items[i]) - (i == 0 ? -1 : get<0>(items[i - 1]));
    vector<pii> small_items(N);
    for (int j = 0; j < N; ++j) {
      small_items[j] = pii(get<1>(items[j]), get<2>(items[j]));
    }
    debug() << " ["
            << "small_items"
               ": "
            << (small_items) << "] ";
    const int S = N - i;
    vector<int> order(S);
    iota((order).begin(), (order).end(), i);
    sort((order).begin(), (order).end(),
         [&](int lhs, int rhs) { return small_items[lhs] < small_items[rhs]; });
    debug() << " ["
            << "order"
               ": "
            << (order) << "] ";
    vector<int> in_order(N, -1);
    for (int j = 0; j < S; ++j) {
      in_order[order[j]] = j;
    }
    debug() << " ["
            << "i"
               ": "
            << (i) << "] "
            << " ["
            << "in_order"
               ": "
            << (in_order) << "] ";
    vi locs, cols;
    for (int idx : order) {
      locs.push_back(small_items[idx].first);
      cols.push_back(small_items[idx].second);
    }
    IntvCounter intv_counter(cols, locs);
    for (int j = N - 1; j >= i; --j) {
      const int diff_right =
          (j == N - 1 ? X - 1 : get<0>(items[j + 1]) - 1) - get<0>(items[j]);
      debug() << " ["
              << "diff_left"
                 ": "
              << (diff_left) << "] "
              << " ["
              << "diff_right"
                 ": "
              << (diff_right) << "] "
              << " ["
              << "intv_counter.sum"
                 ": "
              << (intv_counter.sum) << "] ";
      ans = add(ans, mul(diff_left, mul(diff_right + 1, intv_counter.sum)));
      const int where = in_order[j];
      assert(where >= 0);
      intv_counter.DelItem(where);
    }
  }
  cout << ans << "\n";
}