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 std::cin;
using std::cout;
using std::log2;
constexpr int mod = 1000000007;
constexpr int kmax = 2000;
constexpr int nmax = 2000;
constexpr int lmax = 1000000000;
struct node {
  int size, maxf, sum;
};
struct candy {
  int x, y, c;
};
int n, k, L;
candy m[nmax + 1];
std::vector<int> xmap, ymap;
std::set<int> cset[kmax + 1];
node smt[nmax * 2];
int lazy[nmax];
int next[nmax + 1], prev[nmax + 1];
void input() {
  cin >> n >> k >> L;
  for (int i = 1; i <= n; ++i) {
    cin >> m[i].x >> m[i].y >> m[i].c;
    xmap.push_back(m[i].x);
    ymap.push_back(m[i].y);
  }
}
int comx(int x) {
  return std::lower_bound(xmap.begin(), xmap.end(), x) - xmap.begin();
}
int comy(int y) {
  return std::lower_bound(ymap.begin(), ymap.end(), y) - ymap.begin();
}
void preprocessing() {
  std::sort(xmap.begin(), xmap.end());
  xmap.resize(std::unique(xmap.begin(), xmap.end()) - xmap.begin());
  std::sort(ymap.begin(), ymap.end());
  ymap.resize(std::unique(ymap.begin(), ymap.end()) - ymap.begin());
  for (int i = 1; i <= n; ++i) {
    m[i].x = comx(m[i].x);
    m[i].y = comy(m[i].y);
  }
  std::sort(m + 1, m + n + 1, [](const candy &l, const candy &r) -> bool {
    return (l.y != r.y) ? (l.y < r.y) : (l.x > r.x);
  });
}
int getx(int x) {
  if (x == -1) return -1;
  if (x == xmap.size()) return L;
  return xmap[x];
}
int gety(int y) {
  if (y == -1) return -1;
  if (y == ymap.size()) return L;
  return ymap[y];
}
int cut(int l, int r) {
  int len = r - l + 1;
  int mssb = 1 << int(std::log2(len));
  return l + std::min(len - (mssb >> 1), mssb);
}
void apply(node &d, int f) {
  if (f == -1) return;
  d.maxf = f;
  d.sum = ((long long)d.size * (L - getx(f))) % mod;
}
void combine(node &d, const node &l, const node &r) {
  d.maxf = r.maxf;
  d.sum = (l.sum + r.sum) % mod;
}
void add(int &d, int s) {
  if (d < s) d = s;
}
void propagate(int id) {
  if (lazy[id] != -1) {
    apply(smt[id << 1], lazy[id]);
    apply(smt[id << 1 | 1], lazy[id]);
    if ((id << 1) < xmap.size()) add(lazy[id << 1], lazy[id]);
    if ((id << 1 | 1) < xmap.size()) add(lazy[id << 1 | 1], lazy[id]);
    lazy[id] = -1;
  }
}
void init_(int id, int l, int r) {
  if (l == r) {
    smt[id].size = getx(l) - getx(l - 1);
    return;
  }
  int mid = cut(l, r);
  init_(id << 1, l, mid - 1);
  init_(id << 1 | 1, mid, r);
  smt[id].size = smt[id << 1].size + smt[id << 1 | 1].size;
}
void init() { init_(1, 0, xmap.size() - 1); }
void reset_(int id, int l, int r) {
  if (l == r) {
    smt[id].maxf = l;
    smt[id].sum = ((long long)smt[id].size * (L - xmap[l])) % mod;
    return;
  }
  lazy[id] = -1;
  int mid = cut(l, r);
  reset_(id << 1, l, mid - 1);
  reset_(id << 1 | 1, mid, r);
  combine(smt[id], smt[id << 1], smt[id << 1 | 1]);
}
void reset() { reset_(1, 0, xmap.size() - 1); }
int get_prev(int i) {
  auto it = cset[m[i].c].upper_bound(m[i].x);
  if (it == cset[m[i].c].begin()) return -1;
  return *(--it);
}
int get_next(int i) {
  auto it = cset[m[i].c].lower_bound(m[i].x);
  if (it == cset[m[i].c].end()) return xmap.size();
  return *it;
}
int find_first(int id, int l, int r, int f) {
  if (l == r) return l + (smt[id].maxf < f);
  if (smt[id].maxf < f) return r + 1;
  propagate(id);
  int mid = cut(l, r);
  int res = find_first(id << 1, l, mid - 1, f);
  if (res == mid) res = find_first(id << 1 | 1, mid, r, f);
  return res;
}
int find_first(int f) { return find_first(1, 0, xmap.size() - 1, f); }
int cl, cr, cv;
void update(int id, int l, int r) {
  if (cl <= l && r <= cr) {
    apply(smt[id], cv);
    if (id < xmap.size()) add(lazy[id], cv);
    return;
  }
  propagate(id);
  int mid = cut(l, r);
  if (cl < mid) update(id << 1, l, mid - 1);
  if (mid <= cr) update(id << 1 | 1, mid, r);
  combine(smt[id], smt[id << 1], smt[id << 1 | 1]);
}
void update_max(int l, int r, int v) {
  if (r < l) return;
  int r_ = find_first(v);
  if (r_ <= l) return;
  cl = l;
  cr = std::min(r, r_ - 1);
  cv = v;
  update(1, 0, xmap.size() - 1);
}
int delete_row(int y, int first) {
  int cur = first;
  while (cur < n && m[cur + 1].y == y) {
    ++cur;
    update_max(prev[cur] + 1, m[cur].x, next[cur]);
  }
  return cur;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  input();
  preprocessing();
  init();
  int ans = 0;
  for (int yu = 0, last = 0; yu < ymap.size(); ++yu) {
    while (last < n && m[last + 1].y == yu) ++last;
    reset();
    for (int c = 1; c <= k; ++c) cset[c].clear();
    for (int i = last; i >= 1; --i) {
      prev[i] = get_prev(i);
      next[i] = get_next(i);
      cset[m[i].c].insert(m[i].x);
    }
    for (int c = 1; c <= k; ++c) {
      int last = -1;
      for (int x : cset[c]) {
        update_max(last + 1, x, x);
        last = x;
      }
      update_max(last + 1, xmap.size() - 1, xmap.size());
    }
    for (int yd = 0, cur = 0; yd <= yu; ++yd) {
      int add = (((long long)(gety(yd) - gety(yd - 1)) *
                  (gety(yu + 1) - gety((yu)))) %
                 mod * smt[1].sum) %
                mod;
      ans = (ans + add) % mod;
      cur = delete_row(yd, cur);
    }
  }
  cout << ans;
  return 0;
}