Problem: There used to be unrest in the Galactic Senate. Several thousand solar systems had declared their intentions to leave the Republic. But fear not! Master Heidi was able to successfully select the Jedi Knights that have restored peace in the galaxy. However, she knows that evil never sleeps and a time may come when she will need to pick another group of Jedi Knights. She wants to be sure she has enough options to do so.

There are n Jedi Knights, each of them with a lightsaber of one of m colors. Given a number k, compute the number of differently colored collections of k lightsabers that some k Jedi Knights might have. Jedi Knights with lightsabers of the same color are indistinguishable (it's not the person, it's the lightsaber color that matters!), and their order does not matter; that is, we consider two collections of Jedi Knights to be different if and only if their vectors of counts of lightsabers of each color (like what you were given in the easy and the medium versions) are different. We count all subsets, not only contiguous subsegments of the input sequence. Output the answer modulo 1009.

Input

The first line of the input contains n (1 ≤ n ≤ 2·105), m (1 ≤ m ≤ n) and k (1 ≤ k ≤ n). The second line contains n integers in the range {1, 2, ..., m} representing colors of the lightsabers of subsequent Jedi Knights.

Output

Output one number: the number of differently colored collections of k lightsabers modulo 1009.

Example

Input

4 3 2
1 2 3 2


Output

4

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int mod = 1009;
struct base {
  double x, y;
  base() { x = y = 0; }
  base(double _x, double _y) { x = _x, y = _y; }
  base(double _x) { x = _x, y = 0; }
  void operator=(double _x) { x = _x, y = 0; }
  double real() { return x; }
  double imag() { return y; }
  base operator+(const base& b) { return base(x + b.x, y + b.y); }
  void operator+=(const base& b) { x += b.x, y += b.y; }
  base operator*(const base& b) {
    return base(x * b.x - y * b.y, x * b.y + y * b.x);
  }
  void operator*=(const base& b) {
    double p = x * b.x - y * b.y, q = x * b.y + y * b.x;
    x = p, y = q;
  }
  void operator/=(double k) { x /= k, y /= k; }
  base operator-(const base& b) { return base(x - b.x, y - b.y); }
  void operator-=(const base& b) { x -= b.x, y -= b.y; }
};
double PI = 2.0 * acos(0.0);
const int MAXN = 21;
const int maxn = (1 << MAXN);
base W[maxn], invW[maxn];
void precompute_powers() {
  for (int i = 0; i < maxn / 2; i++) {
    double ang = (2 * PI * i) / maxn;
    double _cos = cos(ang), _sin = sin(ang);
    W[i] = base(_cos, _sin);
    invW[i] = base(_cos, -_sin);
  }
}
void fft(vector<base>& a, bool invert) {
  int n = (int)a.size();
  for (int i = 1, j = 0; i < n; ++i) {
    int bit = n >> 1;
    for (; j >= bit; bit >>= 1) j -= bit;
    j += bit;
    if (i < j) swap(a[i], a[j]);
  }
  for (int len = 2; len <= n; len <<= 1) {
    for (int i = 0; i < n; i += len) {
      int ind = 0, add = maxn / len;
      for (int j = 0; j < len / 2; ++j) {
        base u = a[i + j],
             v = (a[i + j + len / 2] * (invert ? invW[ind] : W[ind]));
        a[i + j] = (u + v);
        a[i + j + len / 2] = (u - v);
        ind += add;
      }
    }
  }
  if (invert)
    for (int i = 0; i < n; ++i) a[i] /= n;
}
inline int add(int x, int y) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
inline int sub(int x, int y) {
  x -= y;
  if (x < 0) x += mod;
  return x;
}
inline int mul(int x, int y) { return (x * 1ll * y) % mod; }
inline int powr(int a, long long b) {
  int x = 1 % mod;
  while (b) {
    if (b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a) { return powr(a, mod - 2); }
void multiply(vector<int>& a, vector<int> b) {
  if ((a.size() * 1ll * b.size()) <= 1000) {
    vector<int> ret(int((a).size()) + int((b).size()) - 1);
    for (__typeof(int((a).size())) i = (0) - ((0) > (int((a).size())));
         i != (int((a).size())) - ((0) > (int((a).size()))); i += 1)
      for (__typeof(int((b).size())) j = (0) - ((0) > (int((b).size())));
           j != (int((b).size())) - ((0) > (int((b).size()))); j += 1)
        ret[i + j] = add(ret[i + j], mul(a[i], b[j]));
    a = ret;
    return;
  }
  vector<base> fa(a.begin(), a.end()), fb(b.begin(), b.end());
  int fsz = a.size() + b.size() - 1;
  int n = 1;
  while (n < fsz) n <<= 1;
  fa.resize(n), fb.resize(n);
  fft(fa, false), fft(fb, false);
  for (size_t i = 0; i < n; ++i) fa[i] *= fb[i];
  fft(fa, true);
  a.resize(fsz);
  for (int i = 0; i < fsz; i++) a[i] = ((long long)(fa[i].real() + 0.5)) % mod;
}
vector<int> mul(vector<int> a, vector<int> b) {
  multiply(a, b);
  return a;
}
vector<int> get(vector<vector<int> >& V) {
  if (V.size() == 1) return V[0];
  int mid = (V.size() >> 1);
  vector<vector<int> > lft(V.begin(), V.begin() + mid);
  vector<vector<int> > rgt(V.begin() + mid, V.end());
  return mul(get(lft), get(rgt));
}
int f[N];
int main() {
  precompute_powers();
  int n, m, k;
  scanf("%d", &(n));
  scanf("%d", &(m));
  scanf("%d", &(k));
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &(x));
    f[x]++;
  }
  vector<vector<int> > v;
  for (int i = 0; i < N; i++) {
    if (f[i]) {
      vector<int> z;
      for (int j = 0; j <= f[i]; j++) z.push_back(1);
      v.push_back(z);
    }
  }
  random_shuffle(v.begin(), v.end());
  printf("%d\n", get(v)[k]);
}