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 INF = 1e9 + 7;
struct Tree {
  int n;
  vector<long long> t;
  vector<int> mx;
  vector<int> val;
  vector<int> weights;
  void add_val(int v, int l, int r, int now) {
    t[v] = weights[v] * (long long)now;
    mx[v] = now;
    val[v] = now;
  }
  void push(int v, int l, int r) {
    if (val[v] == -1) return;
    int m = (l + r) / 2;
    add_val(2 * v, l, m, val[v]);
    add_val(2 * v + 1, m, r, val[v]);
    val[v] = -1;
  }
  void relax(int v) {
    t[v] = t[2 * v] + t[2 * v + 1];
    mx[v] = max(mx[2 * v], mx[2 * v + 1]);
    weights[v] = weights[2 * v] + weights[2 * v + 1];
  }
  void build(vector<int>& a, vector<int>& w, int v, int l, int r) {
    if (r - l == 1) {
      t[v] = a[l] * (long long)w[l];
      mx[v] = a[l];
      weights[v] = w[l];
      return;
    }
    int m = (l + r) / 2;
    build(a, w, 2 * v, l, m);
    build(a, w, 2 * v + 1, m, r);
    relax(v);
  }
  Tree(vector<int>& a, vector<int>& w)
      : n(a.size()), t(4 * n), val(4 * n, -1), weights(4 * n), mx(4 * n) {
    build(a, w, 1, 0, n);
  }
  long long get_sum(int l, int r, int vt, int lt, int rt) {
    if (l >= rt || lt >= r) {
      return 0;
    }
    if (l <= lt && rt <= r) {
      return t[vt];
    }
    push(vt, lt, rt);
    int mt = (lt + rt) / 2;
    auto first = get_sum(l, r, 2 * vt, lt, mt);
    auto second = get_sum(l, r, 2 * vt + 1, mt, rt);
    relax(vt);
    return first + second;
  }
  long long get_sum(int l, int r) { return get_sum(l, r, 1, 0, n); }
  void change_max(int l, int r, int now, int vt, int lt, int rt) {
    if (l >= rt || lt >= r) {
      return;
    }
    int mt = (lt + rt) / 2;
    if (l <= lt && rt <= r) {
      if (mx[vt] < now) {
        add_val(vt, lt, rt, now);
        return;
      }
      if (rt - lt == 1) return;
      push(vt, lt, rt);
      if (mx[2 * vt] < now) {
        add_val(2 * vt, lt, mt, now);
        change_max(l, r, now, 2 * vt + 1, mt, rt);
      } else {
        change_max(l, r, now, 2 * vt, lt, mt);
      }
      relax(vt);
      return;
    }
    push(vt, lt, rt);
    change_max(l, r, now, 2 * vt, lt, mt);
    change_max(l, r, now, 2 * vt + 1, mt, rt);
    relax(vt);
  }
  void change_max(int l, int r, int now) { change_max(l, r, now, 1, 0, n); }
  int get_pos(int val, int vt, int lt, int rt) {
    if (rt - lt == 1) {
      return (t[vt] >= val ? lt : -1);
    }
    push(vt, lt, rt);
    int mt = (lt + rt) / 2;
    if (mx[2 * vt] >= val) {
      return get_pos(val, 2 * vt, lt, mt);
    }
    return get_pos(val, 2 * vt + 1, mt, rt);
  }
  int get_pos(int val) { return get_pos(val, 1, 0, n); }
  void print(int vt, int lt, int rt) {
    if (rt - lt == 1) {
      cout << mx[vt] << " ";
      return;
    }
    push(vt, lt, rt);
    int mt = (lt + rt) / 2;
    print(2 * vt, lt, mt);
    print(2 * vt + 1, mt, rt);
    relax(vt);
  }
  void print() {
    cout << "FXS\n";
    print(1, 0, n);
    cout << "\n";
  }
};
void add(int& first, int second) {
  first += second;
  if (first >= INF) {
    first -= INF;
  }
  if (first < 0) {
    first += INF;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k, L;
  cin >> n >> k >> L;
  set<int> xs;
  set<int> ys;
  vector<int> color(n);
  vector<pair<int, int>> points(n);
  map<int, vector<int>> ymp;
  for (int i = 0; i < n; ++i) {
    int c, first, second;
    cin >> first >> second >> c;
    --c;
    color[i] = c;
    points[i] = {first, second};
    ymp[second].push_back(i);
    xs.insert(first);
    ys.insert(second);
  }
  ys.insert(L);
  map<int, int> nx;
  vector<int> xval;
  int now = 0;
  for (int first : xs) {
    nx[first] = now++;
    xval.push_back(first);
  }
  int res = 0;
  vector<pair<int, int>> xcur;
  vector<multiset<int>> allx(k);
  int y_prev = 0;
  for (int y_up : ys) {
    vector<int> fx;
    vector<int> lens;
    map<int, int> posq;
    int pr = 0;
    for (auto t : xcur) {
      lens.push_back(xval[t.first] - pr + 1);
      posq[t.first] = lens.size() - 1;
      pr = xval[t.first] + 1;
    }
    lens.push_back(L - pr);
    vector<int> color_count(k, 0);
    int exist_colors = 0;
    int rt = 0;
    while (rt < (int)xcur.size() && exist_colors < k) {
      int c = xcur[rt].second;
      ++color_count[c];
      exist_colors += (color_count[c] == 1);
      ++rt;
    }
    if (exist_colors == k) {
      fx.push_back(xval[xcur[rt - 1].first]);
    }
    for (int lt = 0; lt < (int)xcur.size(); ++lt) {
      int c = xcur[lt].second;
      --color_count[c];
      exist_colors -= (color_count[c] == 0);
      while (rt < (int)xcur.size() && exist_colors < k) {
        int c = xcur[rt].second;
        ++color_count[c];
        exist_colors += (color_count[c] == 1);
        ++rt;
      }
      if (exist_colors == k) {
        fx.push_back(xval[xcur[rt - 1].first]);
      } else
        break;
    }
    while (fx.size() < lens.size()) {
      fx.push_back(L);
    }
    Tree tree(fx, lens);
    pr = 0;
    for (int y_down : ys) {
      if (y_down == y_up) break;
      int dy = y_down - pr + 1;
      int ddy = y_up - y_prev;
      add(res, ddy * (long long)dy % INF *
                   ((L * (long long)L - tree.get_sum(0, fx.size())) % INF) %
                   INF);
      for (auto ind : ymp[y_down]) {
        int first = nx[points[ind].first];
        int c = color[ind];
        allx[c].erase(allx[c].find(first));
      }
      vector<pair<int, pair<int, int>>> queries;
      for (auto ind : ymp[y_down]) {
        int first = nx[points[ind].first];
        int c = color[ind];
        int x_ind =
            upper_bound(xcur.begin(), xcur.end(), make_pair(first, INF)) -
            xcur.begin() - 1;
        auto it = allx[c].lower_bound(first);
        int prv = 0, nxt;
        if (it != allx[c].end()) {
          nxt = xval[*it];
        } else {
          nxt = L;
        }
        it = allx[c].upper_bound(first);
        if (it != allx[c].begin()) {
          prv = posq[*(--it)] + 1;
        }
        prv = max(prv, tree.get_pos(xval[first]));
        queries.push_back({x_ind, {prv, nxt}});
      }
      sort(queries.rbegin(), queries.rend());
      for (auto t : queries) {
        int x_ind = t.first;
        int prv = t.second.first;
        int nxt = t.second.second;
        tree.change_max(prv, x_ind + 1, nxt);
      }
      pr = y_down + 1;
    }
    for (auto ind : ymp[y_up]) {
      xcur.push_back({nx[points[ind].first], color[ind]});
    }
    sort(xcur.begin(), xcur.end());
    for (int i = 0; i < k; ++i) {
      allx[i].clear();
    }
    for (auto t : xcur) {
      allx[t.second].insert(t.first);
    }
    y_prev = y_up;
  }
  cout << res << "\n";
}