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;
inline int read() {
  char c;
  int x = 0;
  int b = 1;
  do {
    c = getchar();
    if (c == 45) b = -1;
  } while (c > 57 || c < 48);
  do x = x * 10 + c - 48, c = getchar();
  while (c <= 57 && c >= 48);
  x *= b;
  return x;
}
const int maxn = 2010, mod = 1e9 + 7;
int i, j, k, n, m, L;
int X[maxn], Y[maxn], c[maxn][maxn], cnt0, cnt1, s0 = 1, s1 = 1;
struct edge {
  int x, y, c;
} E[maxn];
int cnt;
vector<pair<int, int> > C[maxn], C2[maxn];
void init() {
  sort(X + 1, X + 1 + cnt0);
  sort(Y + 1, Y + 1 + cnt1);
  for (int i = 2; i <= cnt0; i++)
    if (X[i] != X[i - 1]) X[++s0] = X[i];
  for (int i = 2; i <= cnt1; i++)
    if (Y[i] != Y[i - 1]) Y[++s1] = Y[i];
  for (int i = 1; i <= cnt; i++) {
    int x0 = lower_bound(X + 1, X + 1 + s0, E[i].x) - X,
        y0 = lower_bound(Y + 1, Y + 1 + s1, E[i].y) - Y;
    c[x0][y0] = E[i].c;
    C[y0].push_back((pair<int, int>){x0, E[i].c});
    C2[x0].push_back((pair<int, int>){y0, E[i].c});
  }
}
int ans[maxn], last[maxn], nxt[maxn], S[maxn];
multiset<int> Mp[maxn];
multiset<int>::iterator it;
int is[maxn];
long long Ans;
namespace Segment_tree {
int tree[maxn * 4], Min[maxn * 4], lazy[maxn * 4];
long long w[maxn * 4];
void update(int root) {
  Min[root] = min(Min[root * 2], Min[root * 2 + 1]);
  tree[root] = (tree[root * 2] + tree[root * 2 + 1]) % mod;
}
void pushdown(int root, int L, int R) {
  if (!lazy[root]) return;
  lazy[root * 2] = lazy[root];
  Min[root * 2] = lazy[root];
  tree[root * 2] = w[root * 2] * lazy[root] % mod;
  lazy[root * 2 + 1] = lazy[root];
  Min[root * 2 + 1] = lazy[root];
  tree[root * 2 + 1] = w[root * 2 + 1] * lazy[root] % mod;
  lazy[root] = 0;
}
void build(int root, int L, int R, int *ans, int *y) {
  if (L == R) {
    Min[root] = ans[L];
    tree[root] = 1ll * ans[L] * (y[L] - y[L - 1]) % mod;
    w[root] = y[L] - y[L - 1];
    lazy[root] = 0;
  } else {
    build(root * 2, L, ((L + R) >> 1), ans, y);
    build(root * 2 + 1, ((L + R) >> 1) + 1, R, ans, y);
    update(root);
    w[root] = (w[root * 2] + w[root * 2 + 1]) % mod;
    lazy[root] = 0;
  }
}
int find(int root, int L, int R, int s) {
  if (L == R) {
    if (Min[root] <= s)
      return L;
    else
      return L - 1;
  } else {
    pushdown(root, L, R);
    if (Min[root * 2 + 1] <= s)
      return find(root * 2 + 1, ((L + R) >> 1) + 1, R, s);
    else
      return find(root * 2, L, ((L + R) >> 1), s);
  }
}
void add(int root, int L, int R, int l, int r, int s) {
  if (L == l && R == r) {
    lazy[root] = s;
    Min[root] = s;
    tree[root] = 1ll * s * w[root] % mod;
  } else {
    pushdown(root, L, R);
    if (r <= ((L + R) >> 1))
      add(root * 2, L, ((L + R) >> 1), l, r, s);
    else if (l > ((L + R) >> 1))
      add(root * 2 + 1, ((L + R) >> 1) + 1, R, l, r, s);
    else
      add(root * 2, L, ((L + R) >> 1), l, ((L + R) >> 1), s),
          add(root * 2 + 1, ((L + R) >> 1) + 1, R, ((L + R) >> 1) + 1, r, s);
    update(root);
  }
}
long long updateans(int L, int s1) {
  long long sum = L * w[1] % mod - tree[1] + w[1];
  return (sum + 1000000007) % (1000000007);
}
}  // namespace Segment_tree
using namespace Segment_tree;
int main() {
  ;
  cin >> n >> m >> L;
  X[++cnt0] = L + 1;
  Y[++cnt1] = L + 1;
  for (i = 1; i <= n; i++) {
    int x = read() + 1, y = read() + 1, C = read();
    E[++cnt] = {x, y, C};
    X[++cnt0] = x;
    Y[++cnt1] = y;
  }
  init();
  for (int x = 1; x < s0; x++) {
    int all = 0, p = 0;
    memset(last, -1, sizeof(last));
    for (int co = 1; co <= m; co++) Mp[co].clear();
    for (int l = 1; l <= s1; l++) nxt[l] = s1 + 1;
    memset(ans, -1, sizeof(ans));
    for (int l = 1; l <= s1; l++) {
      while (all != m && p < s1) {
        ++p;
        for (int k = 0; k < C[p].size(); k++) {
          int xs = C[p][k].first, c = C[p][k].second;
          if (xs <= x) {
            Mp[c].insert(p);
            is[c]++;
            all += (is[c] == 1);
          }
        }
        if (all == m) break;
      }
      if (all == m)
        ans[l] = Y[p];
      else
        ans[l] = Y[s1];
      for (int k = 0; k < C[l].size(); k++) {
        int xs = C[l][k].first, c = C[l][k].second;
        if (xs <= x) {
          is[c]--;
          all -= (is[c] == 0);
        }
      }
    }
    build(1, 1, s1, ans, Y);
    Ans += updateans(L, s0) * (X[x + 1] - X[x]) % mod * (X[1] - X[0]) % mod;
    (Ans = Ans >= mod ? Ans - mod : Ans);
    for (int h = 2; h <= x; h++) {
      for (int k = 0; k < C2[h - 1].size(); k++) {
        int y = C2[h - 1][k].first, c = C2[h - 1][k].second;
        Mp[c].erase(Mp[c].find(y));
        int L, R;
        it = Mp[c].upper_bound(y);
        if (it == Mp[c].end())
          R = Y[s1];
        else
          R = Y[*it];
        if (it == Mp[c].begin())
          L = 1;
        else {
          --it;
          L = *it;
          L++;
        }
        int rig = find(1, 1, s1, R);
        if (L <= rig) add(1, 1, s1, L, rig, R);
      }
      Ans +=
          updateans(L, s0) * (X[x + 1] - X[x]) % mod * (X[h] - X[h - 1]) % mod;
      (Ans = Ans >= mod ? Ans - mod : Ans);
    }
  }
  cout << Ans << endl;
  return 0;
}