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;
long long read() {
  long long x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f = ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  return f ? -x : x;
}
template <class T>
void ckmax(T &x, const T y) {
  if (x < y) x = y;
}
template <class T>
void ckmin(T &x, const T y) {
  if (x > y) x = y;
}
const int mod = 1e9 + 7;
int Pow(int x, int y) {
  int ans = 1;
  for (; y; y >>= 1, x = (long long)x * x % mod)
    if (y & 1) ans = (long long)ans * x % mod;
  return ans;
}
void Add(int &x, int y) {
  if ((x += y) >= mod) x -= mod;
}
void Del(int &x, int y) {
  if ((x -= y) < 0) x += mod;
}
int Add(int x) { return x >= mod ? x - mod : x; }
int Del(int x) { return x < 0 ? x + mod : x; }
int md(long long x) { return (x % mod + mod) % mod; }
const int N = 2005, INF = 1.05e9;
int n, k, L;
vector<int> hx, hy;
int hsx, hsy;
struct P {
  int x, y, c;
} a[N];
int gid(vector<int> &h, int v) {
  return lower_bound(h.begin(), h.end(), v) - h.begin();
}
namespace seg {
const int S = N * 4;
int mi[S], mx[S], c[S], s[S];
int cov[S];
void pushup(int rt) {
  int ls = rt << 1, rs = ls | 1;
  mi[rt] = min(mi[ls], mi[rs]);
  mx[rt] = max(mx[ls], mx[rs]);
  s[rt] = Add(s[ls] + s[rs]);
}
void pushdown(int rt) {
  if (cov[rt] != -1) {
    int ls = rt << 1, rs = ls | 1;
    cov[ls] = cov[rs] = cov[rt];
    mi[ls] = mi[rs] = mx[ls] = mx[rs] = cov[rt];
    s[ls] = (long long)mi[ls] * c[ls] % mod;
    s[rs] = (long long)mi[rs] * c[rs] % mod;
    cov[rt] = -1;
  }
}
void build(int rt, int L, int R, int *h) {
  cov[rt] = -1;
  if (L == R) {
    mi[rt] = mx[rt] = hy[h[L]];
    c[rt] = hy[L + 1] - hy[L];
    s[rt] = (long long)c[rt] * mi[rt] % mod;
    return;
  }
  int mid = (L + R) >> 1, ls = rt << 1, rs = ls | 1;
  build(ls, L, mid, h);
  build(rs, mid + 1, R, h);
  pushup(rt);
  c[rt] = Add(c[ls] + c[rs]);
}
void update(int rt, int L, int R, int xL, int xR, int v) {
  if (xL > xR || R < xL || L > xR) return;
  int mid = (L + R) >> 1, ls = rt << 1, rs = ls | 1;
  if (L < R) pushdown(rt);
  if (xL <= L && R <= xR) {
    if (mx[rt] <= v) return;
    if (mi[rt] >= v) {
      cov[rt] = mx[rt] = mi[rt] = v;
      s[rt] = (long long)c[rt] * v % mod;
      return;
    }
    update(ls, L, mid, xL, xR, v);
    update(rs, mid + 1, R, xL, xR, v);
  } else {
    update(ls, L, mid, xL, xR, v);
    update(rs, mid + 1, R, xL, xR, v);
  }
  pushup(rt);
}
int query() { return s[1]; }
}  // namespace seg
vector<int> vx[N], vy[N], vc[N];
int pre[N], nxt[N];
int h[N];
int main() {
  n = read(), k = read(), L = read();
  hx = hy = {0, L + 1};
  for (int i = (1); i <= (n); i++) {
    a[i].x = read() + 1, a[i].y = read() + 1, a[i].c = read();
    hx.push_back(a[i].x);
    hy.push_back(a[i].y);
  }
  sort(hx.begin(), hx.end());
  sort(hy.begin(), hy.end());
  hx.resize(unique(hx.begin(), hx.end()) - hx.begin());
  hy.resize(unique(hy.begin(), hy.end()) - hy.begin());
  hsx = (int)hx.size() - 2;
  hsy = (int)hy.size() - 2;
  for (int i = (1); i <= (n); i++) {
    a[i].x = gid(hx, a[i].x);
    a[i].y = gid(hy, a[i].y);
    vx[a[i].x].push_back(i);
    vy[a[i].y].push_back(i);
  }
  a[0] = {0, 0, 0};
  a[n + 1] = {0, L + 1, 0};
  int ans = 0;
  for (int u = (1); u <= (hsx); u++) {
    for (int i = (1); i <= (k); i++) vc[i].clear();
    for (int i = (1); i <= (n); i++)
      if (a[i].x >= u) vc[a[i].c].push_back(i);
    h[hsy] = hsy;
    for (int i = (1); i <= (k); i++) {
      sort(vc[i].begin(), vc[i].end(),
           [&](int x, int y) { return a[x].y < a[y].y; });
      int las = 0;
      for (auto j : vc[i]) pre[j] = las, nxt[las] = j, las = j;
      nxt[las] = n + 1;
      ckmin(h[hsy], a[las].y);
    }
    nxt[0] = 0;
    for (int i = (hsy); i >= (2); i--) {
      h[i - 1] = h[i];
      for (auto j : vy[i])
        if (a[j].x >= u) ckmin(h[i - 1], a[pre[j]].y);
    }
    seg::build(1, 1, hsy, h);
    for (int i = (hsx); i >= (1); i--) {
      Add(ans, (long long)seg::query() * (hx[i + 1] - hx[i]) % mod *
                   (hx[u] - hx[u - 1]) % mod);
      for (auto j : vx[i]) {
        seg::update(1, 1, hsy, a[j].y, a[nxt[j]].y - 1, hy[a[pre[j]].y]);
        nxt[pre[j]] = nxt[j];
        pre[nxt[j]] = pre[j];
      }
    }
  }
  cout << ans << endl;
  return 0;
}