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 JAVA):

Solution:
import java.io.*;
import java.util.*;

public class Main{
	static void fft(double[] ar, double[] ai, boolean inverse) {
		int n = ar.length;
		
		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) {
				double tmp = ar[i];
				ar[i] = ar[j];
				ar[j] = tmp;
				
				tmp = ai[i];
				ai[i] = ai[j];
				ai[j] = tmp;
			}
		}

		for (int len = 2; len <= n; len <<= 1) {
			double angle = 2 * Math.PI / len * (inverse ? -1 : 1);
			
			int len2 = len>>1;
			
			double wnr = Math.cos(angle);
			double wni = Math.sin(angle);
			
			for (int i = 0; i < n; i += len) {
				
				double wr = 1;
				double wi = 0;
				
				for (int j = 0; j < len2; j++) {
					double ur = ar[i+j];
					double ui = ai[i+j];
					
					double vr = realMult(ar[i+j+len2], ai[i+j+len2], wr, wi);
					double vi = imagMult(ar[i+j+len2], ai[i+j+len2], wr, wi);
					
					ar[i + j] = ur + vr;
					ai[i + j] = ui + vi;
					
					ar[i + j + len / 2] = ur - vr;
					ai[i + j + len / 2] = ui - vi;
					
					
					double twr = wr;
					double twi = wi;
					
					wr = realMult(twr, twi, wnr, wni);
					wi = imagMult(twr, twi, wnr, wni);
				}
			}

		}

		if (inverse)
			for (int i = 0; i < n; i++){
				ar[i] /= n;
				ai[i] /= n;
			}
	}
	
	static double realMult(double ar, double ai, double br, double bi)
	{
		return ar * br - ai * bi;
	}
	
	static double imagMult(double ar, double ai, double br, double bi)
	{
		return ar * bi + ai * br;
	}

	static long[] multiply(long[] a, long[] b) {

		int N = 1;
		while (N < a.length + b.length)
			N <<= 1;

		
		double ar[] = new double[N];
		double ai[] = new double[N];
		
		double br[] = new double[N];
		double bi[] = new double[N];
		
		for (int i = 0; i < a.length; i++) {
			ar[i] = a[i];
		}
		for (int i = 0; i < b.length; i++) {
			br[i] = b[i];
		}

		fft(ar, ai, false);
		
		if(a == b)
		{
			for (int i = 0; i < N; i++) {
				double real = ar[i];
				double imag = ai[i];
				ar[i] = realMult(real, imag, real, imag);
				ai[i] = imagMult(real, imag, real, imag);
			}
		}
		else{
			fft(br, bi, false);
			for (int i = 0; i < N; i++) {
				double real = ar[i];
				double imag = ai[i];
				ar[i] = real * br[i] - imag * bi[i];
				ai[i] = real * bi[i] + imag * br[i];
			}
		}

		fft(ar, ai, true);

		long[] res = new long[N];

		for (int i = 0; i < N; i++) {
			res[i] = (long) (ar[i] + 0.5);
			res[i]%=mod;
		}
		
		return res;
	}
	static int mod=1009;
	static void main() throws Exception{
		int n=sc.nextInt(),m=sc.nextInt(),k=sc.nextInt();
		int[]occ=new int[m];
		for(int i=0;i<n;i++) {
			occ[sc.nextInt()-1]++;
		}
		PriorityQueue<long[]>pq=new PriorityQueue<long[]>((x,y)->x.length-y.length);
		for(int i=0;i<m;i++) {
			if(occ[i]==0)continue;
			long[]cur=new long[occ[i]+1];
			Arrays.fill(cur, 1);
			pq.add(cur);
		}
		while(pq.size()>1) {
			pq.add(multiply(pq.poll(), pq.poll()));
		}
		pw.println(pq.poll()[k]);
	}
    public static void main(String[] args) throws Exception{
        sc=new MScanner(System.in);
        pw = new PrintWriter(System.out);
        int tc=1;
//        tc=sc.nextInt();
        for(int i=1;i<=tc;i++) {
//            pw.printf("Case %d:\n", i);
            main();
        }
        pw.flush();
    }
    static PrintWriter pw;
    static MScanner sc;
    static class MScanner {
        StringTokenizer st;
        BufferedReader br;
        public MScanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }
     
        public MScanner(String file) throws Exception {
            br = new BufferedReader(new FileReader(file));
        }
     
        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }
        public int[] intArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public long[] longArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public int[] intSortedArr(int n) throws IOException {
            int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }
        public long[] longSortedArr(int n) throws IOException {
            long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            shuffle(in);
            Arrays.sort(in);
            return in;
        }
        public Integer[] IntegerArr(int n) throws IOException {
            Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
            return in;
        }
        public Long[] LongArr(int n) throws IOException {
            Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
            return in;
        }
        public String nextLine() throws IOException {
            return br.readLine();
        }
     
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
     
        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
     
        public char nextChar() throws IOException {
            return next().charAt(0);
        }
     
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
     
        public boolean ready() throws IOException {
            return br.ready();
        }
     
        public void waitForInput() throws InterruptedException {
            Thread.sleep(3000);
        }
        
    }
    static void shuffle(int[]in) {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            int tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    }
    static void shuffle(long[]in) {
        for(int i=0;i<in.length;i++) {
            int idx=(int)(Math.random()*in.length);
            long tmp=in[i];
            in[i]=in[idx];
            in[idx]=tmp;
        }
    }
}