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>
const int N = 2005, INF = 0x3f3f3f3f, P = 1000000007;
int n, m, L;
int mx, X[N];
int my, Y[N];
struct Node {
  int x, y, c;
  bool operator<(const Node &rhs) const {
    return x < rhs.x || (x == rhs.x && y < rhs.y);
  }
} a[N];
std::vector<int> p[N];
int top, sta[N];
std::vector<int> add[N], del[N];
int l[N];
struct TNode {
  int mx, cnt, cmx;
  long long sum;
  TNode() {}
  TNode(int v, int len) { mx = v, cnt = len, cmx = -INF, sum = 1ll * len * v; }
};
TNode operator+(const TNode &A, const TNode &B) {
  TNode res;
  res.sum = A.sum + B.sum;
  res.cmx = std::max(A.cmx, B.cmx);
  if (A.mx == B.mx) {
    res.mx = A.mx;
    res.cnt = A.cnt + B.cnt;
  } else if (A.mx > B.mx) {
    res.mx = A.mx;
    res.cnt = A.cnt;
    res.cmx = std::max(res.cmx, B.mx);
  } else {
    res.mx = B.mx;
    res.cnt = B.cnt;
    res.cmx = std::max(res.cmx, A.mx);
  }
  return res;
}
struct SegmentTree {
  static const int N = ::N << 2;
  TNode val[N];
  int tag[N];
  void build(int u, int l, int r) {
    tag[u] = INF;
    if (l == r) {
      val[u] = TNode(INF, X[l] - X[l - 1]);
      return;
    }
    int mid = (l + r) >> 1;
    build(u << 1, l, mid);
    build(u << 1 | 1, mid + 1, r);
    val[u] = val[u << 1] + val[u << 1 | 1];
  }
  void chmin(int u, int v) {
    if (val[u].mx <= v) {
      return;
    }
    tag[u] = v;
    if (val[u].cmx < v) {
      val[u].sum -= 1ll * (val[u].mx - v) * val[u].cnt;
      val[u].mx = v;
      return;
    }
  }
  void down(int u) {
    chmin(u << 1, tag[u]);
    chmin(u << 1 | 1, tag[u]);
    tag[u] = INF;
  }
  void modify(int u, int l, int r, int L, int R, int v) {
    if (val[u].mx <= v) {
      return;
    }
    if (L <= l && r <= R && val[u].cmx < v) {
      chmin(u, v);
      return;
    }
    int mid = (l + r) >> 1;
    down(u);
    if (L <= mid) {
      modify(u << 1, l, mid, L, R, v);
    }
    if (R > mid) {
      modify(u << 1 | 1, mid + 1, r, L, R, v);
    }
    val[u] = val[u << 1] + val[u << 1 | 1];
  }
  long long query(int u, int l, int r, int L, int R) {
    if (L <= l && r <= R) {
      return val[u].sum;
    }
    int mid = (l + r) >> 1;
    down(u);
    if (R <= mid) {
      return query(u << 1, l, mid, L, R);
    } else if (L > mid) {
      return query(u << 1 | 1, mid + 1, r, L, R);
    } else {
      return query(u << 1, l, mid, L, R) + query(u << 1 | 1, mid + 1, r, L, R);
    }
  }
} T;
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cin >> n >> m >> L;
  for (int i = 1; i <= n; ++i) {
    std::cin >> a[i].x >> a[i].y >> a[i].c;
    X[++mx] = a[i].x;
    Y[++my] = a[i].y;
  }
  X[0] = -1, X[++mx] = L;
  Y[0] = -1, Y[++my] = L;
  std::sort(X + 1, X + 1 + mx);
  mx = std::unique(X + 1, X + 1 + mx) - X - 1;
  std::sort(Y + 1, Y + 1 + my);
  my = std::unique(Y + 1, Y + 1 + my) - Y - 1;
  for (int i = 1; i <= n; ++i) {
    a[i].x = std::lower_bound(X + 1, X + 1 + mx, a[i].x) - X;
    a[i].y = std::lower_bound(Y + 1, Y + 1 + my, a[i].y) - Y;
  }
  int ans = 0;
  std::sort(a + 1, a + 1 + n);
  for (int i = 1; i <= n; ++i) {
    p[a[i].c].push_back(i);
  }
  for (int up = 1; up <= my; ++up) {
    for (int i = 1; i <= mx; ++i) {
      add[i].clear();
      del[i].clear();
    }
    T.build(1, 1, mx);
    for (int c = 1; c <= m; ++c) {
      top = 0;
      for (int i = 0; i < (int)p[c].size(); ++i) {
        int id = p[c][i];
        if (a[id].y >= up) {
          continue;
        }
        if (i + 1 < (int)p[c].size() && a[p[c][i + 1]].y < up &&
            a[p[c][i + 1]].x == a[id].x) {
          continue;
        }
        if (top) {
          del[a[id].x].push_back(a[sta[top]].x);
        } else {
          del[a[id].x].push_back(0);
        }
        while (top && a[sta[top]].y <= a[id].y) {
          add[a[id].x].push_back(sta[top]);
          --top;
        }
        if (top) {
          l[id] = a[sta[top]].x;
        } else {
          l[id] = 0;
        }
        sta[++top] = id;
      }
      if (top) {
        del[mx].push_back(a[sta[top]].x);
      } else {
        del[mx].push_back(0);
      }
      while (top) {
        add[mx].push_back(sta[top]);
        --top;
      }
    }
    for (int i = mx; i; --i) {
      for (int v : add[i]) {
        if (l[v] < mx) {
          T.modify(1, 1, mx, l[v] + 1, mx, Y[a[v].y] + 1);
        }
      }
      for (int v : del[i]) {
        if (v < mx) {
          T.modify(1, 1, mx, v + 1, mx, 0);
        }
      }
      ans = (ans + T.query(1, 1, mx, 1, i) % P * (X[i] - X[i - 1]) % P *
                       (Y[up] - Y[up - 1])) %
            P;
    }
  }
  std::cout << ans << "\n";
}