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 long long MAXN = 4000 + 10;
const long long INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
long long n, k, L;
struct point {
  long long x, y, c;
};
long long comp(point a, point b) {
  if (a.y == b.y) return a.x < b.x;
  return a.y < b.y;
}
struct LIST {
  long long prev[MAXN], nxt[MAXN];
  void del(long long x) {
    nxt[prev[x]] = nxt[x];
    prev[nxt[x]] = prev[x];
  }
} lst, lst2;
point a[MAXN];
long long arrX[MAXN], arrY[MAXN], totX, totY, last[MAXN];
vector<long long> px[MAXN], py[MAXN];
long long sum[MAXN << 2], tag[MAXN << 2], minn[MAXN << 2];
long long f[MAXN];
long long calc(long long l, long long r, long long pos) {
  return 1ll * (arrY[r] - arrY[l - 1]) * (L - arrY[pos]) % mod;
}
void pushup(long long node, long long l, long long r) {
  sum[node] = (sum[(node << 1)] + sum[(node << 1 | 1)]) % mod;
  minn[node] = minn[(node << 1)];
}
void build(long long node, long long l, long long r) {
  if (l == r) {
    sum[node] = calc(l, r, f[l]);
    tag[node] = 0;
    minn[node] = f[l];
    return;
  }
  build((node << 1), l, ((l + r) >> 1));
  build((node << 1 | 1), ((l + r) >> 1) + 1, r);
  pushup(node, l, r);
}
void update(long long node, long long l, long long r, long long pos) {
  sum[node] = calc(l, r, pos);
  tag[node] = pos;
  minn[node] = pos;
}
void pushdown(long long node, long long l, long long r) {
  if (!tag[node]) return;
  update((node << 1), l, ((l + r) >> 1), tag[node]);
  update((node << 1 | 1), ((l + r) >> 1) + 1, r, tag[node]);
  tag[node] = 0;
  return;
}
void change(long long node, long long l, long long r, long long from,
            long long to, long long pos) {
  if (l > to || r < from) return;
  if (from <= l && r <= to) {
    update(node, l, r, pos);
    return;
  }
  pushdown(node, l, r);
  change((node << 1), l, ((l + r) >> 1), from, to, pos);
  change((node << 1 | 1), ((l + r) >> 1) + 1, r, from, to, pos);
  pushup(node, l, r);
}
long long findPos(long long node, long long l, long long r, long long cmp) {
  if (l == r) {
    if (minn[node] >= cmp) return 0;
    return l;
  }
  pushdown(node, l, r);
  if (minn[node] >= cmp) return 0;
  if (minn[(node << 1 | 1)] < cmp)
    return findPos((node << 1 | 1), ((l + r) >> 1) + 1, r, cmp);
  else
    return findPos((node << 1), l, ((l + r) >> 1), cmp);
}
inline void init(void) {
  cin >> n >> k >> L;
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i].y >> a[i].x >> a[i].c;
    arrX[i] = a[i].x, arrY[i] = a[i].y;
  }
  sort(arrX + 1, arrX + n + 1);
  sort(arrY, arrY + n + 1);
  totX = unique(arrX + 1, arrX + n + 1) - arrX - 1;
  totY = unique(arrY + 1, arrY + n + 1) - arrY - 1;
  arrY[totY + 1] = L;
  arrX[totX + 1] = L;
  arrX[0] = -1;
  arrY[0] = -1;
  a[0].y = 0;
  a[n + 1].y = totY + 1;
  sort(a + 1, a + 1 + n, comp);
  for (long long i = 1; i <= n; ++i) {
    a[i].x = lower_bound(arrX + 1, arrX + totX + 1, a[i].x) - arrX;
    a[i].y = lower_bound(arrY + 1, arrY + totY + 1, a[i].y) - arrY;
    px[a[i].x].push_back(i);
    py[a[i].y].push_back(i);
  }
  for (long long i = 1; i <= n; ++i) {
    lst.prev[i] = last[a[i].c];
    lst.nxt[last[a[i].c]] = i;
    lst.nxt[i] = n + 1;
    last[a[i].c] = i;
  }
}
void print(long long x, long long l, long long r) {
  cout << x << " " << sum[x] << endl;
  pushdown(x, l, r);
  if (l == r) return;
  print(x << 1, l, ((l + r) >> 1));
  print(x << 1 | 1, ((l + r) >> 1) + 1, r);
}
long long cnt[MAXN];
long long ans;
inline void work(void) {
  for (long long front = 1; front <= totX; ++front) {
    memset(sum, INF, sizeof(sum));
    memset(cnt, 0, sizeof(cnt));
    long long now = 0;
    memset(tag, 0, sizeof(tag));
    for (long long i = 1; i <= totY; ++i) f[i] = 0;
    for (long long lt = 1, rt = 1; lt <= totY; ++lt) {
      for (; now < k && rt <= totY; ++rt) {
        for (auto i : py[rt]) {
          if (a[i].x < front) continue;
          if (cnt[a[i].c] == 0) ++now;
          cnt[a[i].c]++;
        }
      }
      if (now == k)
        f[lt] = rt - 1;
      else
        f[lt] = totY + 1;
      for (auto i : py[lt]) {
        if (a[i].x < front) continue;
        if (cnt[a[i].c] == 1) --now;
        cnt[a[i].c]--;
      }
    }
    build(1, 1, totY);
    lst2 = lst;
    for (long long back = totX; back >= front; --back) {
      ans = (ans + 1ll * sum[1] * (arrX[back + 1] - arrX[back]) % mod *
                       (arrX[front] - arrX[front - 1]) % mod) %
            mod;
      for (auto i : px[back]) {
        long long loc = findPos(1, 1, totY, a[lst2.nxt[i]].y);
        if (loc < a[lst2.prev[i]].y + 1) {
          lst2.del(i);
          continue;
        }
        change(1, 1, totY, a[lst2.prev[i]].y + 1, loc, a[lst2.nxt[i]].y);
        lst2.del(i);
      }
    }
    for (auto i : px[front]) lst.del(i);
  }
  cout << ans;
}
int main() {
  init();
  work();
  return 0;
}