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 double eps = 1e-9;
const int oo = 0x3f3f3f3f;
vector<int> yvalues;
const long long MOD = 1e9 + 7;
struct Data {
  int data_low, data_high;
  long long data_vol;
  Data(int data_low_, int data_high_, long long data_vol_)
      : data_low(data_low_), data_high(data_high_), data_vol(data_vol_) {}
};
struct SegmentTree {
  int S;
  int SP2;
  struct Entry {
    Data data;
    Entry(int data_low_, int data_high_, long long data_vol_)
        : data(data_low_, data_high_, data_vol_) {}
  };
  vector<Entry> entries;
  SegmentTree(int N) {
    S = N;
    entries = vector<Entry>(S * 2 + 2, Entry(0, 0, 0));
    SP2 = 1;
    while (SP2 * 2 <= S) SP2 *= 2;
  }
  long long query() { return entries[0].data.data_vol; }
  void update(int f, int t, int least_height);
  bool debugTree();
  void reset(int f, int t);
  void init(vector<Data> &initialValues);
  int get_mid(int D, int P2) {
    return (((P2 >> 1) | P2) <= D) ? P2 : D - (P2 >> 1);
  }
  void update(int id, int P2, int F, int T, int f, int t, int leastHeight,
              int leastHeightParent) {
    f = max(f, F);
    t = min(t, T);
    if (leastHeightParent > entries[id].data.data_low) {
      assert(leastHeightParent >= entries[id].data.data_high);
      entries[id].data = {
          leastHeightParent, leastHeightParent,
          leastHeightParent * (long long)(yvalues[T] - yvalues[F])};
    }
    if (f >= t) return;
    if (leastHeight <= entries[id].data.data_low) return;
    if (f == F && t == T && leastHeight >= entries[id].data.data_high) {
      entries[id].data = {leastHeight, leastHeight,
                          leastHeight * (long long)(yvalues[T] - yvalues[F])};
    } else {
      int M = F + get_mid(T - F, P2);
      update(id * 2 + 1, P2 >> 1, F, M, f, t, leastHeight,
             max(leastHeightParent, entries[id].data.data_low));
      update(id * 2 + 2, P2 >> 1, M, T, f, t, leastHeight,
             max(leastHeightParent, entries[id].data.data_low));
      auto &ec1 = entries[id * 2 + 1].data;
      auto &ec2 = entries[id * 2 + 2].data;
      ;
      ;
      entries[id].data = {ec2.data_low, ec1.data_high,
                          ec1.data_vol + ec2.data_vol};
    };
    ;
  }
};
void SegmentTree::update(int f, int t, int change) {
  update(0, SP2, 0, S, f, t, change, 0);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N, K;
  long long L;
  cin >> N >> K >> L;
  vector<vector<pair<int, int> > > xy(K);
  for (__typeof__(N) i = (0) - ((0) > (N)); i != ((N) - ((0) > (N)));
       i += 1 - 2 * ((0) > (N))) {
    int x, y, c;
    cin >> x >> y >> c;
    xy[c - 1].push_back({x, y});
  }
  map<int, int> yvaluesMap;
  {
    set<int> yvaluesS;
    for (auto &it : xy)
      for (auto p : it) yvaluesS.insert(p.second);
    yvaluesS.insert(0);
    yvaluesS.insert((int)L);
    yvalues = vector<int>((yvaluesS).begin(), (yvaluesS).end());
    for (__typeof__(int((yvalues).size())) i =
             (0) - ((0) > (int((yvalues).size())));
         i != ((int((yvalues).size())) - ((0) > (int((yvalues).size()))));
         i += 1 - 2 * ((0) > (int((yvalues).size()))))
      yvaluesMap[yvalues[i]] = i;
    for (auto &it : xy)
      for (auto &p : it) p.second = yvaluesMap[p.second];
  }
  for (__typeof__(K) i = (0) - ((0) > (K)); i != ((K) - ((0) > (K)));
       i += 1 - 2 * ((0) > (K)))
    sort((xy[i]).begin(), (xy[i]).end());
  ;
  ;
  ;
  ;
  long long res = 0;
  int DY = -1;
  for (__typeof__(int((yvalues).size())) ys =
           (0) - ((0) > (int((yvalues).size())));
       ys != ((int((yvalues).size())) - ((0) > (int((yvalues).size()))));
       ys += 1 - 2 * ((0) > (int((yvalues).size())))) {
    for (__typeof__(K) k = (0) - ((0) > (K)); k != ((K) - ((0) > (K)));
         k += 1 - 2 * ((0) > (K))) {
      int U = 0;
      for (__typeof__(int((xy[k]).size())) i =
               (0) - ((0) > (int((xy[k]).size())));
           i != ((int((xy[k]).size())) - ((0) > (int((xy[k]).size()))));
           i += 1 - 2 * ((0) > (int((xy[k]).size())))) {
        if (xy[k][i].second >= ys) {
          xy[k][U++] = xy[k][i];
        }
      }
      xy[k].resize(U);
    };
    ;
    SegmentTree segtree(int((yvalues).size()));
    vector<tuple<int, int, int, int> > changes;
    for (__typeof__(K) k = (0) - ((0) > (K)); k != ((K) - ((0) > (K)));
         k += 1 - 2 * ((0) > (K))) {
      ;
      ;
      stack<pair<int, int> > pareto;
      pareto.push({-1, L});
      for (__typeof__(0) i =
               (int((xy[k]).size())) - ((int((xy[k]).size())) > (0));
           i != ((0) - ((int((xy[k]).size())) > (0)));
           i += 1 - 2 * ((int((xy[k]).size())) > (0))) {
        ;
        ;
        auto p = xy[k][i];
        int x, y;
        tie(x, y) = p;
        if (i > 0 && xy[k][i - 1].first == x) continue;
        int D = int((yvalues).size()) - 1;
        while (y <= pareto.top().first) {
          changes.push_back({x, pareto.top().first, D, pareto.top().second});
          D = pareto.top().first;
          pareto.pop();
        }
        if (D != y) {
          changes.push_back({x, y, D, pareto.top().second});
        }
        pareto.push({y, x});
      }
      {
        int D = int((yvalues).size()) - 1;
        while (!pareto.empty()) {
          auto p = pareto.top();
          int y, x;
          tie(y, x) = p;
          ;
          ;
          segtree.update(0, D, x);
          ;
          ;
          D = y;
          pareto.pop();
        }
      }
    }
    sort((changes).begin(), (changes).end());
    ;
    ;
    int DX = -1;
    long long cres = 0;
    for (auto ch : changes) {
      int x, ylo, yhi, xc;
      tie(x, ylo, yhi, xc) = ch;
      if (x != DX) {
        ;
        ;
        cres += ((x - DX) * ((L * (long long)L - segtree.query()) % MOD)) % MOD;
        cres %= MOD;
        DX = x;
      };
      ;
      segtree.update(0, yhi, xc);
      ;
      ;
    }
    cres *= yvalues[ys] - DY;
    DY = yvalues[ys];
    cres %= MOD;
    res += cres;
    res %= MOD;
    ;
    ;
  }
  res = (MOD + (res % MOD)) % MOD;
  cout << res << endl;
  return 0;
}