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 N = 2019, Mod = 1e9 + 7;
int n, m, q, k, lenx, leny, L, X[N], Y[N], C[N], F[N][N], Val[N];
vector<int> UX, UY, Stk[N];
vector<pair<int, int> > V[N], VV[N];
vector<tuple<int, int, int> > E[N];
int MN[N * 4], Cnt[N * 4], LZ[N * 4];
long long SM[N * 4];
void Build(int id = 1, int l = 1, int r = lenx + 1) {
  LZ[id] = -1;
  Cnt[id] = UX[r - 1] - UX[l - 1];
  if (r - l < 2) {
    MN[id] = Val[l];
    SM[id] = (long long)Cnt[id] * MN[id];
    return;
  }
  Build((id << 1), l, ((l + r) >> 1));
  Build(((id << 1) ^ 1), ((l + r) >> 1), r);
  MN[id] = min(MN[(id << 1)], MN[((id << 1) ^ 1)]);
  SM[id] = SM[(id << 1)] + SM[((id << 1) ^ 1)];
}
inline void Shift(int id) {
  if (LZ[id] == -1) return;
  MN[(id << 1)] = MN[((id << 1) ^ 1)] = LZ[(id << 1)] = LZ[((id << 1) ^ 1)] =
      LZ[id];
  SM[(id << 1)] = (long long)Cnt[(id << 1)] * LZ[id];
  SM[((id << 1) ^ 1)] = (long long)Cnt[((id << 1) ^ 1)] * LZ[id];
  LZ[id] = -1;
  return;
}
int Find(int val, int id = 1, int l = 1, int r = lenx + 1) {
  if (MN[id] > val) return lenx + 1;
  if (r - l < 2) return l;
  Shift(id);
  if (MN[(id << 1)] <= val) return Find(val, (id << 1), l, ((l + r) >> 1));
  return Find(val, ((id << 1) ^ 1), ((l + r) >> 1), r);
}
void SetVal(int le, int ri, int val, int id = 1, int l = 1, int r = lenx + 1) {
  if (ri <= l || r <= le) return;
  if (le <= l && r <= ri) {
    MN[id] = val;
    SM[id] = (long long)Cnt[id] * val;
    LZ[id] = val;
    return;
  }
  Shift(id);
  SetVal(le, ri, val, (id << 1), l, ((l + r) >> 1));
  SetVal(le, ri, val, ((id << 1) ^ 1), ((l + r) >> 1), r);
  MN[id] = min(MN[(id << 1)], MN[((id << 1) ^ 1)]);
  SM[id] = SM[(id << 1)] + SM[((id << 1) ^ 1)];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k >> L;
  UX.push_back(0);
  UY.push_back(0);
  for (int i = 1; i <= n; i++) {
    cin >> X[i] >> Y[i] >> C[i];
    X[i]++;
    Y[i]++;
    UX.push_back(X[i]);
    UY.push_back(Y[i]);
  }
  UX.push_back(L + 1);
  UY.push_back(L + 1);
  sort(UX.begin(), UX.end());
  UX.resize(unique(UX.begin(), UX.end()) - UX.begin());
  sort(UY.begin(), UY.end());
  UY.resize(unique(UY.begin(), UY.end()) - UY.begin());
  for (int i = 1; i <= n; i++) {
    X[i] = lower_bound(UX.begin(), UX.end(), X[i]) - UX.begin();
    Y[i] = lower_bound(UY.begin(), UY.end(), Y[i]) - UY.begin();
  }
  lenx = (int)UX.size() - 2;
  leny = (int)UY.size() - 2;
  int tot = 0;
  for (int ry = 1; ry < (int)UY.size() - 1; ry++) {
    for (int rx = 1; rx <= lenx; rx++) {
      VV[rx].clear();
      V[rx].clear();
      E[rx].clear();
    }
    for (int i = 1; i <= k; i++) Stk[i].clear();
    for (int i = 1; i <= n; i++)
      if (Y[i] <= ry) VV[X[i]].push_back({C[i], Y[i]});
    for (int rx = 1; rx <= lenx; rx++) {
      sort(VV[rx].begin(), VV[rx].end());
      for (int i = 0; i < (int)VV[rx].size(); i++)
        if (i + 1 == (int)VV[rx].size() ||
            VV[rx][i].first != VV[rx][i + 1].first)
          V[rx].push_back(VV[rx][i]), F[rx][VV[rx][i].first] = VV[rx][i].second;
    }
    for (int i = 1; i <= k; i++) Stk[i].push_back(0);
    for (int rx = 1; rx <= lenx; rx++) {
      for (auto e : V[rx]) {
        int c = e.first, y = e.second;
        E[rx].push_back(make_tuple(Stk[c].back() + 1, rx + 1, UY[0]));
        while (Stk[c].size() > 1 && F[Stk[c].back()][c] <= y) {
          int lst = Stk[c].back();
          Stk[c].pop_back();
          E[rx].push_back(
              make_tuple(Stk[c].back() + 1, lst + 1, UY[F[lst][c]]));
        }
        Stk[c].push_back(rx);
      }
    }
    set<pair<int, int> > ST;
    vector<int> TMp(k + 3, 0);
    for (int i = 1; i <= k; i++) ST.insert({0, i});
    for (int rx = lenx; rx >= 1; rx--) {
      for (auto e : V[rx]) {
        int c = e.first, y = e.second;
        if (TMp[c] >= y) continue;
        ST.erase({TMp[c], c});
        TMp[c] = y;
        ST.insert({TMp[c], c});
      }
      Val[rx] = UY[ST.begin()->first];
    }
    Build();
    int curtot = 0;
    for (int rx = lenx; rx >= 1; rx--) {
      curtot =
          (curtot + (SM[1] % Mod) * (long long)(UX[rx + 1] - UX[rx])) % Mod;
      for (auto e : E[rx]) {
        int l, r, val;
        tie(l, r, val) = e;
        int rr = Find(val);
        r = min(r, rr);
        if (l < r) SetVal(l, r, val);
      }
    }
    tot = (tot + (long long)curtot * (UY[ry + 1] - UY[ry])) % Mod;
  }
  printf("%d\n", tot);
  return 0;
}