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 comment(linker, "/STACK:1000000000")
#pragma GCC optimize("Ofast,no-stack-protector")
using namespace std;
const int maxn = 2010, mod = (int)1e9 + 7;
pair<pair<int, int>, int> v[maxn];
int len;
int add(int x, int y) {
  x += y;
  if (x >= mod) {
    x -= mod;
  }
  return x;
}
int sub(int x, int y) {
  x -= y;
  if (x < 0) {
    x += mod;
  }
  return x;
}
int mul(int x, int y) { return (long long)x * y % mod; }
struct vt {
  int w;
  int maxr;
  int minr;
  int st;
  int ans;
};
vector<vt> g;
vt t[4 * maxn];
vt recalc(vt a, vt b) {
  vt ans;
  ans.st = -1;
  ans.ans = add(a.ans, b.ans);
  ans.w = add(a.w, b.w);
  ans.maxr = max(a.maxr, b.maxr);
  ans.minr = min(a.minr, b.minr);
  return ans;
}
void build(int it, int l, int r) {
  if (l == r) {
    t[it] = g[l];
  } else {
    int m = (l + r) >> 1;
    build(2 * it, l, m);
    build(2 * it + 1, m + 1, r);
    t[it] = recalc(t[2 * it], t[2 * it + 1]);
  }
}
void sets(int it, int l, int r, int x) {
  t[it].maxr = x;
  t[it].minr = x;
  t[it].st = x;
  t[it].ans = mul(sub(len, x), t[it].w);
}
void push(int it, int l, int r) {
  if (t[it].st != -1) {
    int m = (l + r) >> 1;
    sets(2 * it, l, m, t[it].st);
    sets(2 * it + 1, m + 1, r, t[it].st);
    t[it].st = -1;
  }
}
void change(int it, int l, int r, int pos, int lm, int rm) {
  if (t[it].maxr < lm || t[it].minr >= rm) {
    return;
  }
  if (l != r) {
    push(it, l, r);
  }
  if (r < pos) {
    return;
  }
  int m = (l + r) >> 1;
  if (l < pos) {
    change(2 * it, l, m, pos, lm, rm);
    change(2 * it + 1, m + 1, r, pos, lm, rm);
    t[it] = recalc(t[2 * it], t[2 * it + 1]);
  } else if (lm <= t[it].minr && t[it].maxr < rm) {
    sets(it, l, r, rm);
  } else {
    change(2 * it, l, m, pos, lm, rm);
    change(2 * it + 1, m + 1, r, pos, lm, rm);
    t[it] = recalc(t[2 * it], t[2 * it + 1]);
  }
}
int tot = 0;
int used[maxn];
multiset<int> cl[maxn];
void change(int pos, int x) {
  if (used[pos]) {
    tot--;
  }
  used[pos] += x;
  if (used[pos]) {
    tot++;
  }
}
int main() {
  int n, k;
  cin >> n >> k >> len;
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &v[i].first.first, &v[i].first.second, &v[i].second);
    v[i].second--;
  }
  sort(v, v + n);
  int res = 0;
  for (int i = 0; i < n; i++) {
    tot = 0;
    memset(used, 0, sizeof used);
    vector<pair<pair<int, int>, int> > f;
    for (int j = 0; j < k; j++) {
      cl[j].clear();
      cl[j].insert(len);
    }
    for (int j = i; j < n; j++) {
      f.push_back(make_pair(make_pair(v[j].first.second, v[j].second), j));
      cl[v[j].second].insert(v[j].first.second);
    }
    sort((f).begin(), (f).end());
    g.clear();
    g.resize(f.size());
    int rm = 0;
    for (int j = 0; j < (int)f.size(); j++) {
      while (rm < (int)f.size() && tot < k) {
        change(f[rm].first.second, 1);
        rm++;
      }
      g[j].st = -1;
      g[j].maxr = g[j].minr = (tot == k ? f[rm - 1].first.first : len);
      g[j].w = (j == 0 ? f[j].first.first + 1
                       : f[j].first.first - f[j - 1].first.first);
      g[j].ans = mul(g[j].w, sub(len, g[j].maxr));
      change(f[j].first.second, -1);
      assert(rm > j);
    }
    build(1, 0, (int)f.size() - 1);
    int ans = mul(t[1].ans, sub(len, v[n - 1].first.first));
    for (int j = n - 1; j > i; j--) {
      int y = v[j].first.second;
      int c = v[j].second;
      auto itr = cl[c].lower_bound(y);
      int pos = 0;
      if (itr != cl[c].begin()) {
        itr--;
        pos = lower_bound((f).begin(), (f).end(),
                          make_pair(make_pair(*itr, c), (int)1e9)) -
              f.begin();
        itr++;
      }
      assert(itr != cl[c].end());
      itr++;
      assert(itr != cl[c].end());
      change(1, 0, (int)f.size() - 1, pos, y, *itr);
      itr--;
      cl[c].erase(itr);
      ans = add(ans, mul(t[1].ans, v[j].first.first - v[j - 1].first.first));
    }
    ans = mul(ans, (i ? v[i].first.first - v[i - 1].first.first
                      : v[i].first.first + 1));
    res = add(res, ans);
  }
  cout << res << '\n';
}