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;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 2003, M = 1000000007;
int n, k, L;
int x[N], y[N], c[N];
vector<int> vx;
vector<int> vy;
vector<pair<int, int> > v[N];
multiset<int> ss[N];
int maxu[N * 4];
int minu[N * 4];
int s[N * 4];
vector<int> gg[N];
int g[N];
int q[N], qq;
void bil(int tl, int tr, int pos) {
  if (tl == tr) {
    minu[pos] = maxu[pos] = g[tl];
    if (tl == 0)
      s[pos] = (vy[tr]) * 1LL * (L - vy[g[tl]] + 1) % M;
    else
      s[pos] = (vy[tr] - vy[tl - 1]) * 1LL * (L - vy[g[tl]] + 1) % M;
    return;
  }
  int m = (tl + tr) / 2;
  bil(tl, m, pos * 2);
  bil(m + 1, tr, pos * 2 + 1);
  maxu[pos] = max(maxu[pos * 2], maxu[pos * 2 + 1]);
  minu[pos] = min(minu[pos * 2], minu[pos * 2 + 1]);
  s[pos] = (s[pos * 2] + s[pos * 2 + 1]) % M;
}
void shi(int tl, int tr, int pos) {
  if (minu[pos] != maxu[pos]) return;
  int m = (tl + tr) / 2;
  minu[pos * 2] = maxu[pos * 2] = minu[pos * 2 + 1] = maxu[pos * 2 + 1] =
      minu[pos];
  if (tl == 0)
    s[pos * 2] = (vy[m]) * 1LL * (L - vy[minu[pos]] + 1) % M;
  else
    s[pos * 2] = (vy[m] - vy[tl - 1]) * 1LL * (L - vy[minu[pos]] + 1) % M;
  s[pos * 2 + 1] = (vy[tr] - vy[m]) * 1LL * (L - vy[minu[pos]] + 1) % M;
}
void ubd(int tl, int tr, int l, int r, int y, int pos) {
  if (l > r) return;
  if (minu[pos] >= y) return;
  if (tl == l && tr == r) {
    if (maxu[pos] <= y) {
      maxu[pos] = minu[pos] = y;
      if (l == 0)
        s[pos] = (vy[r]) * 1LL * (L - vy[y] + 1) % M;
      else
        s[pos] = (vy[r] - vy[l - 1]) * 1LL * (L - vy[y] + 1) % M;
      return;
    }
    if (tl == tr) return;
  }
  shi(tl, tr, pos);
  int m = (tl + tr) / 2;
  ubd(tl, m, l, min(m, r), y, pos * 2);
  ubd(m + 1, tr, max(m + 1, l), r, y, pos * 2 + 1);
  maxu[pos] = max(maxu[pos * 2], maxu[pos * 2 + 1]);
  minu[pos] = min(minu[pos * 2], minu[pos * 2 + 1]);
  s[pos] = (s[pos * 2] + s[pos * 2 + 1]) % M;
}
void solv() {
  cin >> n >> k >> L;
  for (int i = 1; i <= n; ++i) {
    cin >> x[i] >> y[i] >> c[i];
    ++x[i];
    ++y[i];
  }
  for (int i = 1; i <= n; ++i) {
    vx.push_back(x[i]);
    vy.push_back(y[i]);
  }
  sort((vx).begin(), (vx).end());
  sort((vy).begin(), (vy).end());
  vy.push_back(L + 1);
  vx.push_back(L + 1);
  vector<int> vv;
  for (int i = 0; i < vx.size(); ++i) {
    if (!i || vx[i] != vx[i - 1]) vv.push_back(vx[i]);
  }
  vx = vv;
  vv.clear();
  for (int i = 0; i < vy.size(); ++i) {
    if (!i || vy[i] != vy[i - 1]) vv.push_back(vy[i]);
  }
  vy = vv;
  for (int i = 1; i <= n; ++i) {
    int xx = lower_bound((vx).begin(), (vx).end(), x[i]) - vx.begin();
    int yy = lower_bound((vy).begin(), (vy).end(), y[i]) - vy.begin();
    v[xx].push_back(make_pair(yy, c[i]));
  }
  int ans = 0;
  for (int l = 0; l < ((int)(vx).size()) - 1; ++l) {
    for (int i = 0; i < ((int)(vy).size()) - 1; ++i) gg[i].clear();
    for (int i = 1; i <= k; ++i) ss[i].clear();
    for (int i = l; i < ((int)(vx).size()) - 1; ++i) {
      for (int j = 0; j < v[i].size(); ++j) {
        ss[v[i][j].second].insert(v[i][j].first);
        gg[v[i][j].first].push_back(v[i][j].second);
      }
    }
    bool ff = true;
    for (int i = 1; i <= k; ++i) {
      if (ss[i].empty()) {
        ff = false;
        break;
      }
    }
    if (!ff) continue;
    qq = 0;
    for (int i = 0; i < ((int)(vy).size()) - 1; ++i) {
      g[i] = -1;
      if (i) g[i] = g[i - 1];
      while (1) {
        if (qq == k) break;
        if (g[i] == ((int)(vy).size()) - 1) break;
        ++g[i];
        if (g[i] == ((int)(vy).size()) - 1) break;
        for (int j = 0; j < gg[g[i]].size(); ++j) {
          ++q[gg[g[i]][j]];
          if (q[gg[g[i]][j]] == 1) ++qq;
        }
      }
      for (int j = 0; j < gg[i].size(); ++j) {
        --q[gg[i][j]];
        if (q[gg[i][j]] == 0) --qq;
      }
    }
    bil(0, ((int)(vy).size()) - 2, 1);
    int la;
    if (l == 0)
      la = vx[l];
    else
      la = (vx[l] - vx[l - 1]);
    for (int i = ((int)(vx).size()) - 2; i >= l; --i) {
      ans = (ans + s[1] * 1LL * (vx[i + 1] - vx[i]) % M * 1LL * la % M) % M;
      for (int j = 0; j < v[i].size(); ++j) {
        ss[v[i][j].second].erase(ss[v[i][j].second].find(v[i][j].first));
        if (ss[v[i][j].second].empty()) {
          s[1] = -1;
          break;
        }
        auto it = ss[v[i][j].second].lower_bound(v[i][j].first);
        if (it == ss[v[i][j].second].end()) {
          --it;
          ubd(0, ((int)(vy).size()) - 2, *it + 1, ((int)(vy).size()) - 2,
              ((int)(vy).size()) - 1, 1);
        } else {
          if (*it == v[i][j].first) continue;
          if (it == ss[v[i][j].second].begin()) {
            int u = *it;
            ubd(0, ((int)(vy).size()) - 2, 0, ((int)(vy).size()) - 2, u, 1);
          } else {
            int u = *it;
            --it;
            ubd(0, ((int)(vy).size()) - 2, *it + 1, ((int)(vy).size()) - 2, u,
                1);
          }
        }
      }
      if (s[1] == -1) break;
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  int tt = 1;
  while (tt--) solv();
  return 0;
}