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 int M = 1000000007;
struct mint {
  int val = 0;
  mint() {}
  mint(int a) : val(a) {
    while (val < 0) {
      val += M;
    }
    while (val >= M) {
      val -= M;
    }
  }
  mint(long long a) : val(a % M) {
    if (val < 0) {
      val += M;
    }
  }
  mint operator+=(mint oth) {
    val += oth.val;
    val -= (val >= M) ? M : 0;
    return *this;
  }
  mint operator-=(mint oth) {
    val -= oth.val;
    val += (val < 0) ? M : 0;
    return *this;
  }
  mint operator*=(mint oth) {
    val = 1LL * val * oth.val % M;
    return *this;
  }
  void operator++() {
    ++val;
    if (val == M) {
      val = 0;
    }
  }
  void operator--() {
    --val;
    if (val == -1) {
      val = M - 1;
    }
  }
  mint operator-() {
    mint res;
    res.val = (val == 0) ? 0 : M - val;
    return res;
  }
  friend mint operator+(mint a, mint b) { return mint(a) += b; }
  friend mint operator-(mint a, mint b) { return mint(a) -= b; }
  friend mint operator*(mint a, mint b) { return mint(a) *= b; }
  friend bool operator==(mint a, mint b) { return a.val == b.val; }
  friend bool operator!=(mint a, mint b) { return a.val != b.val; }
  friend ostream &operator<<(ostream &out, mint a) {
    out << a.val;
    return out;
  }
  friend mint pow(mint b, long long e = M - 2) {
    mint res = 1;
    while (e > 0) {
      if (e % 2 == 1) {
        res *= b;
      }
      b *= b;
      e /= 2;
    }
    return res;
  }
};
const int N = 2000;
map<int, int> mono;
mint sum;
int l;
void update(int a, int x) {
  auto it = --mono.upper_bound(a);
  if (it->second <= x) {
    return;
  }
  mono[a] = it->second;
  it = mono.find(a);
  while (it->second >= x) {
    auto nxt = it;
    sum -= (mint)((++nxt)->first - it->first) * (it->second - x);
    mono.erase(it);
    it = nxt;
  }
  mono[a] = x;
}
array<int, 3> candy[N];
multiset<int> where[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k >> l;
  for (int i = 0; i < n; ++i) {
    int x, y, c;
    cin >> x >> y >> c;
    candy[i] = {x, y, c - 1};
  }
  sort(candy, candy + n);
  mint ans = 0;
  for (int i = 0; i < n; ++i) {
    if (i > 0 && candy[i][0] == candy[i - 1][0]) {
      continue;
    }
    sum = (mint)l * l;
    mono.clear();
    mono[l] = -1;
    mono[0] = l;
    fill(where, where + k, multiset<int>());
    for (int j = i; j < n; ++j) {
      where[candy[j][2]].insert(candy[j][1]);
    }
    for (int j = 0; j < k; ++j) {
      where[j].insert(l);
      where[j].insert(-1);
      auto it = where[j].begin();
      while (*it < l) {
        auto nxt = it;
        update(*it + 1, l - *(++nxt));
        it = nxt;
      }
    }
    for (int j = n - 1; j >= i; --j) {
      auto [x, y, c] = candy[j];
      if (j == n - 1 || x != candy[j + 1][0]) {
        int above = candy[i][0] - (i == 0 ? -1 : candy[i - 1][0]);
        int below = (j == n - 1 ? l : candy[j + 1][0]) - x;
        ans += sum * above * below;
      }
      multiset<int> &w = where[c];
      w.erase(w.find(y));
      int prv = *(--w.upper_bound(y));
      int nxt = *w.lower_bound(y);
      update(prv + 1, l - nxt);
    }
  }
  cout << ans << "\n";
}