import java.io.*;
import java.util.*;

public class E {

	static class Point {
		int x, y, id;

		public Point(int x, int y, int id) {
			this.x = x;
			this.y = y;
			this.id = id;
		}
	}

	static Comparator<Point> byAngle = new Comparator<E.Point>() {

		@Override
		public int compare(Point o1, Point o2) {
			return -Long.compare((long) o1.x * o2.y, (long) o2.x * o1.y);
		}
	};

	static Comparator<Point> byAngleRev = new Comparator<E.Point>() {

		@Override
		public int compare(Point o1, Point o2) {
			return Long.compare((long) o1.x * o2.y, (long) o2.x * o1.y);
		}
	};

	void submit() {
		int r = nextInt();
		int q = nextInt();

		int[][] qs = new int[q][3];
		int n = 0;

		for (int i = 0; i < q; i++) {

			qs[i][0] = nextInt();
			if (qs[i][0] == 1) {
				n++;
				qs[i][1] = nextInt();
				qs[i][2] = nextInt();
			} else if (qs[i][0] == 2) {
				qs[i][1] = nextInt() - 1;
			} else if (qs[i][0] == 3) {
				qs[i][1] = nextInt() - 1;
				qs[i][2] = nextInt() - 1;
			}
		}

		int[] xs, ys;

		Point[] px, py;

		int[] treeXIdx = new int[n];
		int[] askX;

		Point[] a;

		{
			a = new Point[n];
			int ptr = 0;
			for (int i = 0; i < q; i++) {
				if (qs[i][0] == 1) {
					a[ptr] = new Point(qs[i][1] - r, qs[i][2], ptr);
					ptr++;
				}
			}

			Arrays.sort(a, byAngle);

			for (int i = 0; i < n; i++) {
				treeXIdx[a[i].id] = i;
			}

			px = makeUnique(a, byAngle, false);
			xs = new int[n];

			for (Point p : a) {
				xs[p.id] = Arrays.binarySearch(px, p, byAngle);
			}

			askX = new int[px.length];
			askX[px.length - 1] = n;

			int pptr = px.length - 1;
			for (int i = n - 2; i >= 0; i--) {
				if ((long) a[i].x * a[i + 1].y != (long) a[i].y * a[i + 1].x) {
					askX[--pptr] = i + 1;
				}
			}

			if (pptr != 0) {
				throw new AssertionError();
			}
		}

		{
//			Point[] a = new Point[n];
			int ptr = 0;
			for (int i = 0; i < q; i++) {
				if (qs[i][0] == 1) {
					a[ptr] = new Point(qs[i][1] + r, qs[i][2], ptr);
					ptr++;
				}
			}

			py = makeUnique(a, byAngleRev, true);
			ys = new int[n];

			for (Point p : a) {
				ys[p.id] = Arrays.binarySearch(py, p, byAngleRev);
			}
		}

//		 System.err.println(Arrays.toString(xs));
//		 System.err.println(Arrays.toString(ys));

		int ptr = 0;

		root = new Node(0, n);

		for (int i = 0; i < q; i++) {
			if (qs[i][0] == 1) {
				root.set(treeXIdx[ptr], ys[ptr]);
				ptr++;
			} else if (qs[i][0] == 2) {
				int what = qs[i][1];
				root.set(treeXIdx[what], Integer.MAX_VALUE);
			} else if (qs[i][0] == 3) {
				int p1 = qs[i][1];
				int p2 = qs[i][2];

				int qx = Math.max(xs[p1], xs[p2]);
				int qy = Math.max(ys[p1], ys[p2]);

				if (isInside(px[qx], py[qy])) {
					out.println("NO");
					continue;
				}

				root.set(treeXIdx[p1], Integer.MAX_VALUE);
				root.set(treeXIdx[p2], Integer.MAX_VALUE);

				out.println(root.get(0, askX[qx]) > qy ? "YES" : "NO");

				root.set(treeXIdx[p1], ys[p1]);
				root.set(treeXIdx[p2], ys[p2]);
			}
		}
	}

	TreeSet<Integer>[] set;
	Node root;

	static class Node {
		int l, r;
		Node left, right;

		int val;

		public Node(int l, int r) {
			this.l = l;
			this.r = r;
			val = Integer.MAX_VALUE;

			if (r - l > 1) {
				int m = (l + r) >> 1;
				left = new Node(l, m);
				right = new Node(m, r);
			}
		}

		void set(int x, int y) {
			if (r - l == 1) {
				val = y;
				return;
			}
			(x < left.r ? left : right).set(x, y);
			val = Math.min(left.val, right.val);
		}

		int get(int ql, int qr) {
			if (ql <= l && r <= qr) {
				return val;
			}
			if (l >= qr || ql >= r) {
				return Integer.MAX_VALUE;
			}
			return Math.min(left.get(ql, qr), right.get(ql, qr));
		}
	}

	boolean isInside(Point vl, Point vr) {
		return (long) vl.x * vr.x + (long) vl.y * vr.y < 0;
	}

	Point[] makeUnique(Point[] a, Comparator<Point> cmp, boolean doSort) {
		a = a.clone();
		if (doSort) {
			Arrays.sort(a, cmp);
		}

		int sz = 1;
		for (int i = 1; i < a.length; i++) {
			if ((long) a[i].x * a[sz - 1].y != (long) a[i].y * a[sz - 1].x) {
				a[sz++] = a[i];
			}
		}
		return Arrays.copyOf(a, sz);
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	E() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		// stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new E();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


import java.io.*;
import java.util.*;

public class E {

	static class Point {
		int x, y, id;

		public Point(int x, int y, int id) {
			this.x = x;
			this.y = y;
			this.id = id;
		}
	}

	static Comparator<Point> byAngle = new Comparator<E.Point>() {

		@Override
		public int compare(Point o1, Point o2) {
			return -Long.compare((long) o1.x * o2.y, (long) o2.x * o1.y);
		}
	};

	static Comparator<Point> byAngleRev = new Comparator<E.Point>() {

		@Override
		public int compare(Point o1, Point o2) {
			return Long.compare((long) o1.x * o2.y, (long) o2.x * o1.y);
		}
	};

	void submit() {
		int r = nextInt();
		int q = nextInt();

		int[][] qs = new int[q][3];
		int n = 0;

		for (int i = 0; i < q; i++) {

			qs[i][0] = nextInt();
			if (qs[i][0] == 1) {
				n++;
				qs[i][1] = nextInt();
				qs[i][2] = nextInt();
			} else if (qs[i][0] == 2) {
				qs[i][1] = nextInt() - 1;
			} else if (qs[i][0] == 3) {
				qs[i][1] = nextInt() - 1;
				qs[i][2] = nextInt() - 1;
			}
		}

		int[] xs, ys;

		Point[] px, py;

		int[] treeXIdx = new int[n];
		int[] askX;

		Point[] a;

		{
			a = new Point[n];
			int ptr = 0;
			for (int i = 0; i < q; i++) {
				if (qs[i][0] == 1) {
					a[ptr] = new Point(qs[i][1] - r, qs[i][2], ptr);
					ptr++;
				}
			}

			Arrays.sort(a, byAngle);

			for (int i = 0; i < n; i++) {
				treeXIdx[a[i].id] = i;
			}

			px = makeUnique(a, byAngle, false);
			xs = new int[n];

			for (Point p : a) {
				xs[p.id] = Arrays.binarySearch(px, p, byAngle);
			}

			askX = new int[px.length];
			askX[px.length - 1] = n;

			int pptr = px.length - 1;
			for (int i = n - 2; i >= 0; i--) {
				if ((long) a[i].x * a[i + 1].y != (long) a[i].y * a[i + 1].x) {
					askX[--pptr] = i + 1;
				}
			}

			if (pptr != 0) {
				throw new AssertionError();
			}
		}

		{
//			Point[] a = new Point[n];
			int ptr = 0;
			for (int i = 0; i < q; i++) {
				if (qs[i][0] == 1) {
					a[ptr] = new Point(qs[i][1] + r, qs[i][2], ptr);
					ptr++;
				}
			}

			py = makeUnique(a, byAngleRev, true);
			ys = new int[n];

			for (Point p : a) {
				ys[p.id] = Arrays.binarySearch(py, p, byAngleRev);
			}
		}

		int ptr = 0;

		down = 1;
		while (down < n) {
			down <<= 1;
		}

		tree = new int[2 * down - 1];
		Arrays.fill(tree, Integer.MAX_VALUE);

		for (int i = 0; i < q; i++) {
			if (qs[i][0] == 1) {
				rootSet(treeXIdx[ptr], ys[ptr]);
				ptr++;
			} else if (qs[i][0] == 2) {
				int what = qs[i][1];
				rootSet(treeXIdx[what], Integer.MAX_VALUE);
			} else if (qs[i][0] == 3) {
				int p1 = qs[i][1];
				int p2 = qs[i][2];

				int qx = Math.max(xs[p1], xs[p2]);
				int qy = Math.max(ys[p1], ys[p2]);

				if (isInside(px[qx], py[qy])) {
					out.println("NO");
					continue;
				}

				rootSet(treeXIdx[p1], Integer.MAX_VALUE);
				rootSet(treeXIdx[p2], Integer.MAX_VALUE);

				out.println(rootGet(0, askX[qx] - 1) > qy ? "YES" : "NO");

				rootSet(treeXIdx[p1], ys[p1]);
				rootSet(treeXIdx[p2], ys[p2]);
			}
		}
	}

	int[] tree;
	int down;

	void rootSet(int pos, int val) {
		pos += down - 1;
		tree[pos] = val;
		while (pos > 0) {
			pos = (pos - 1) >> 1;
			tree[pos] = Math.min(tree[(pos << 1) + 1], tree[(pos << 1) + 2]);
		}
	}

	int rootGet(int from, int to) {
		from += down - 1;
		to += down - 1;
		int ret = Integer.MAX_VALUE;
		while (from < to) {
			if ((from & 1) == 0) {
				ret = Math.min(ret, tree[from]);
				from++;
			}
			if ((to & 1) == 1) {
				ret = Math.min(ret, tree[to]);
				to--;
			}
			from = (from - 1) >> 1;
			to = (to - 1) >> 1;
		}
		if (from == to) {
			ret = Math.min(ret, tree[from]);
		}
		return ret;
	}

	boolean isInside(Point vl, Point vr) {
		return (long) vl.x * vr.x + (long) vl.y * vr.y < 0;
	}

	Point[] makeUnique(Point[] a, Comparator<Point> cmp, boolean doSort) {
		a = a.clone();
		if (doSort) {
			Arrays.sort(a, cmp);
		}

		int sz = 1;
		for (int i = 1; i < a.length; i++) {
			if ((long) a[i].x * a[sz - 1].y != (long) a[i].y * a[sz - 1].x) {
				a[sz++] = a[i];
			}
		}
		return Arrays.copyOf(a, sz);
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	E() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
//		System.err.println((-1) >> 1);
		submit();
//		 stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new E();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


import java.io.*;
import java.util.*;

public class E {

	static class Point {
		int x, y, id;

		public Point(int x, int y, int id) {
			this.x = x;
			this.y = y;
			this.id = id;
		}
	}

	static Comparator<Point> byAngle = new Comparator<E.Point>() {

		@Override
		public int compare(Point o1, Point o2) {
			return -Long.compare((long) o1.x * o2.y, (long) o2.x * o1.y);
		}
	};

	static Comparator<Point> byAngleRev = new Comparator<E.Point>() {

		@Override
		public int compare(Point o1, Point o2) {
			return Long.compare((long) o1.x * o2.y, (long) o2.x * o1.y);
		}
	};

	void submit() {
		int r = nextInt();
		int q = nextInt();

		int[][] qs = new int[q][3];
		int n = 0;

		for (int i = 0; i < q; i++) {

			qs[i][0] = nextInt();
			if (qs[i][0] == 1) {
				n++;
				qs[i][1] = nextInt();
				qs[i][2] = nextInt();
			} else if (qs[i][0] == 2) {
				qs[i][1] = nextInt() - 1;
			} else if (qs[i][0] == 3) {
				qs[i][1] = nextInt() - 1;
				qs[i][2] = nextInt() - 1;
			}
		}

		int[] xs, ys;

		Point[] px, py;

		int[] treeXIdx = new int[n];
		int[] askX;

		{
			Point[] a = new Point[n];
			int ptr = 0;
			for (int i = 0; i < q; i++) {
				if (qs[i][0] == 1) {
					a[ptr] = new Point(qs[i][1] - r, qs[i][2], ptr);
					ptr++;
				}
			}

			Arrays.sort(a, byAngle);

			for (int i = 0; i < n; i++) {
				treeXIdx[a[i].id] = i;
			}

			px = makeUnique(a, byAngle);
			xs = new int[n];

			for (Point p : a) {
				xs[p.id] = Arrays.binarySearch(px, p, byAngle);
			}

			askX = new int[px.length];
			askX[px.length - 1] = n;

			int pptr = px.length - 1;
			for (int i = n - 2; i >= 0; i--) {
//				if (byAngle.compare(a[i], a[i + 1]) != 0) {
				if ((long)a[i].x * a[i + 1].y != (long)a[i].y * a[i + 1].x) {
					askX[--pptr] = i + 1;
				}
			}

			if (pptr != 0) {
				throw new AssertionError();
			}
		}

		{
			Point[] a = new Point[n];
			int ptr = 0;
			for (int i = 0; i < q; i++) {
				if (qs[i][0] == 1) {
					a[ptr] = new Point(qs[i][1] + r, qs[i][2], ptr);
					ptr++;
				}
			}

			py = makeUnique(a, byAngleRev);
			ys = new int[n];

			for (Point p : a) {
				ys[p.id] = Arrays.binarySearch(py, p, byAngleRev);
			}
		}

//		System.err.println(Arrays.toString(xs));
//		System.err.println(Arrays.toString(ys));

		int ptr = 0;

		root = new Node(0, n);

		for (int i = 0; i < q; i++) {
			if (qs[i][0] == 1) {
				root.set(treeXIdx[ptr], ys[ptr]);
				ptr++;
			} else if (qs[i][0] == 2) {
				int what = qs[i][1];
				root.set(treeXIdx[what], Integer.MAX_VALUE);
			} else if (qs[i][0] == 3) {
				int p1 = qs[i][1];
				int p2 = qs[i][2];

				int qx = Math.max(xs[p1], xs[p2]);
				int qy = Math.max(ys[p1], ys[p2]);

				if (isInside(px[qx], py[qy])) {
					out.println("NO");
					continue;
				}

				root.set(treeXIdx[p1], Integer.MAX_VALUE);
				root.set(treeXIdx[p2], Integer.MAX_VALUE);

				out.println(root.get(0, askX[qx]) > qy ? "YES" : "NO");

				root.set(treeXIdx[p1], ys[p1]);
				root.set(treeXIdx[p2], ys[p2]);
			}
		}
	}

	TreeSet<Integer>[] set;
	Node root;

	static class Node {
		int l, r;
		Node left, right;

		int val;

		public Node(int l, int r) {
			this.l = l;
			this.r = r;
			val = Integer.MAX_VALUE;

			if (r - l > 1) {
				int m = (l + r) >> 1;
				left = new Node(l, m);
				right = new Node(m, r);
			}
		}

		void set(int x, int y) {
			if (r - l == 1) {
				val = y;
				return;
			}
			(x < left.r ? left : right).set(x, y);
			val = Math.min(left.val, right.val);
		}

		int get(int ql, int qr) {
			if (ql <= l && r <= qr) {
				return val;
			}
			if (l >= qr || ql >= r) {
				return Integer.MAX_VALUE;
			}
			return Math.min(left.get(ql, qr), right.get(ql, qr));
		}
	}

	boolean isInside(Point vl, Point vr) {
		return (long) vl.x * vr.x + (long) vl.y * vr.y < 0;
	}

	Point[] makeUnique(Point[] a, Comparator<Point> cmp) {
		a = a.clone();
		Arrays.sort(a, cmp);

		int sz = 1;
		for (int i = 1; i < a.length; i++) {
			if ((long)a[i].x * a[sz - 1].y != (long)a[i].y * a[sz - 1].x) {
				a[sz++] = a[i];
			}
		}
		return Arrays.copyOf(a, sz);
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	E() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		// stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new E();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.Vector;
public class Main {
	static final long mod=1000000007;
	public static void main(String[] args) {
		long a[]=new long[20];
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long s=sc.nextLong();
		for(int i=0;i<n;i++)
				a[i]=sc.nextLong();
		int len=(1<<n);
		long ans=0;
		for(int i=0;i<len;i++){
			long x=s;
			int flag=1;
			for(int j=0;j<len;j++)
				if(((i>>j)&1)==1){
					flag*=-1;
					x-=a[j]+1;
				}
			if(x<0)
				continue;
			ans=(ans+flag*lucas(x+n-1,n-1))%mod;
			ans=(ans+mod)%mod;
		}
		System.out.println(ans);
	}
	static long lucas(long a,long b){
		if(b==0)
			return 1;
		return getc(a%mod,b%mod)*lucas(a/mod,b/mod)%mod;
	}
	static long getc(long a,long b){
		if(a<b)
			return 0;
		long ans=1;
		for(long i=a-b+1;i<=a;i++)
			ans=ans*i%mod;
		long t=1;
		for(long i=1;i<=b;i++)
			t=t*i%mod;
		return ans*qpow(t,mod-2)%mod;
	}
	static long qpow(long a,long b){
		long ans=1;
		while(b!=0){
			if((b&1)==1){
				ans=a*ans%mod;
			}
			a=a*a%mod;
			b>>=1;
		}
		return ans;
	}
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 *
 * @author pttrung
 */
public class E_Round_258_Div2 {

	public static long MOD = 1000000007;

	public static void main(String[] args) throws FileNotFoundException {
		// PrintWriter out = new PrintWriter(new FileOutputStream(new File(
		// "output.txt")));
		PrintWriter out = new PrintWriter(System.out);
		Scanner in = new Scanner();
		int n = in.nextInt();
		long s = in.nextInt();
		long[] data = new long[n];
		for (int i = 0; i < n; i++) {
			data[i] = in.nextLong();
		}
		long result = 0;
		for (int i = 1; i < (1 << n); i++) {
			boolean ok = Integer.bitCount(i) <= s;
			long total = 0;
			for (int j = 0; j < n; j++) {
				if (((1 << j) & i) != 0) {
					ok &= data[j] > 0;
					total += data[j];
				}
			}
			ok &= total >= s;
			if (ok) {
				long take = s - Integer.bitCount(i);
				long[] num = new long[Integer.bitCount(i)];
				int index = 0;
				for (int j = 0; j < n; j++) {
					if (((1 << j) & i) != 0) {
						num[index++] = data[j];
					}
				}
				result += cal(take, 0, num);
				result %= MOD;
			}
		}
		out.println(result);
		out.close();
	}

	public static long cal(long need, int total, long[] data) {
		//System.out.println("CALL " + need + " " + total);
		if (total > data.length) {
			return 0;
		}
		long result = 0;
		for (int i = 0; i < (1 << data.length); i++) {
			if (Integer.bitCount(i) == total) {
				long v = need;
				for (int j = 0; j < data.length; j++) {

					if (((1 << j) & i) != 0) {
						v -= data[j];
					}

				}
				if (v >= 0) {
					result += numberOfWay(v, data.length);
					result %= MOD;
				}
			}
		}
		//System.out.println(result + " " + need + " " + total + " " + data.length);
		result -= cal(need, total + 1, data);
		result = (result + MOD) % MOD;
		return result;
	}

	public static long numberOfWay(long v, int n) {
		if(v == 0){
			return 1;
		}
		long x = 1;
		for (long i = v + n - 1; i > v; i--) {
			x *= (i % MOD);
			x %= MOD;
		}
		long y = 1;
		for (long i = 2; i < n; i++) {
			y *= i;
			y %= MOD;
		}
		BigInteger result = BigInteger
				.valueOf(x)
				.multiply(
						BigInteger.valueOf(y).modInverse(
								BigInteger.valueOf(MOD)))
				.mod(BigInteger.valueOf(MOD));
		return result.longValue();
	}

	public static int[] KMP(String val) {
		int i = 0;
		int j = -1;
		int[] result = new int[val.length() + 1];
		result[0] = -1;
		while (i < val.length()) {
			while (j >= 0 && val.charAt(j) != val.charAt(i)) {
				j = result[j];
			}
			j++;
			i++;
			result[i] = j;
		}
		return result;

	}

	public static boolean nextPer(int[] data) {
		int i = data.length - 1;
		while (i > 0 && data[i] < data[i - 1]) {
			i--;
		}
		if (i == 0) {
			return false;
		}
		int j = data.length - 1;
		while (data[j] < data[i - 1]) {
			j--;
		}
		int temp = data[i - 1];
		data[i - 1] = data[j];
		data[j] = temp;
		Arrays.sort(data, i, data.length);
		return true;
	}

	public static int digit(long n) {
		int result = 0;
		while (n > 0) {
			n /= 10;
			result++;
		}
		return result;
	}

	public static double dist(long a, long b, long x, long y) {
		double val = (b - a) * (b - a) + (x - y) * (x - y);
		val = Math.sqrt(val);
		double other = x * x + a * a;
		other = Math.sqrt(other);
		return val + other;

	}

	public static class Point implements Comparable<Point> {

		int x, y;

		public Point(int start, int end) {
			this.x = start;
			this.y = end;
		}

		@Override
		public int hashCode() {
			int hash = 5;
			hash = 47 * hash + this.x;
			hash = 47 * hash + this.y;
			return hash;
		}

		@Override
		public boolean equals(Object obj) {
			if (obj == null) {
				return false;
			}
			if (getClass() != obj.getClass()) {
				return false;
			}
			final Point other = (Point) obj;
			if (this.x != other.x) {
				return false;
			}
			if (this.y != other.y) {
				return false;
			}
			return true;
		}

		@Override
		public int compareTo(Point o) {
			return x - o.x;
		}
	}

	public static class FT {

		long[] data;

		FT(int n) {
			data = new long[n];
		}

		public void update(int index, long value) {
			while (index < data.length) {
				data[index] += value;
				index += (index & (-index));
			}
		}

		public long get(int index) {
			long result = 0;
			while (index > 0) {
				result += data[index];
				index -= (index & (-index));
			}
			return result;

		}
	}

	public static long gcd(long a, long b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	public static long pow(long a, long b) {
		if (b == 0) {
			return 1;
		}
		if (b == 1) {
			return a;
		}
		long val = pow(a, b / 2);
		if (b % 2 == 0) {
			return val * val % MOD;
		} else {
			return val * (val * a % MOD) % MOD;

		}
	}

	static class Scanner {

		BufferedReader br;
		StringTokenizer st;

		public Scanner() throws FileNotFoundException {
			// System.setOut(new PrintStream(new
			// BufferedOutputStream(System.out), true));
			br = new BufferedReader(new InputStreamReader(System.in));
			// br = new BufferedReader(new InputStreamReader(new
			// FileInputStream(new File("input.txt"))));
		}

		public String next() {

			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					throw new RuntimeException();
				}
			}
			return st.nextToken();
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			st = null;
			try {
				return br.readLine();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}

		public boolean endLine() {
			try {
				String next = br.readLine();
				while (next != null && next.trim().isEmpty()) {
					next = br.readLine();
				}
				if (next == null) {
					return true;
				}
				st = new StringTokenizer(next);
				return st.hasMoreTokens();
			} catch (Exception e) {
				throw new RuntimeException();
			}
		}
	}
}


import java.util.*;

import static java.lang.Math.min;

public class Solution {

    private static final long MOD = 1000000007;
    private static long FACT[] = new long[25];

    private static long modPow(long a, long x, long m) {
        long res = 1;
        while(x > 0) {
            if(x % 2 !=0) {
                res = (res*a) % m;
            }
            a = (a*a)%m;
            x /= 2;
        }
        return res % m;
    }

    private static long modInverse(long a, long p) {
        // p doit être premier
        return modPow(a, p - 2, p);
    }

    private static long nCr(long n, int r) {
        if(n < r) return 0;
        r = (int) min(r, n-r);
        long ret = 1;
        for(long x = n; x >= n - r + 1; x--){
            ret = (ret*(x%MOD))%MOD;
        }
        ret = (ret*modInverse(FACT[r], MOD))%MOD;
        return ret;
    }

    public static void main(String[] args) {
        FACT[0] = 1;
        for(int i = 1; i < 25; i++) {
            FACT[i] = (FACT[i - 1]*i)%MOD;
        }

        Scanner in = new Scanner(System.in);
        int n;
        long s, N;
        n = in.nextInt();
        s = in.nextLong();
        long f[] = new long[n];
        for(int i = 0; i < n; i++) {
            f[i] = in.nextInt();
        }

        N = 1 << n;

        long res = 0;
        for(int i = 0; i < N; i++) {
            int count = 0, p = 0;
            for(int j = 0; j < n; j++) {
                if((i & (1 << j) )> 0) {
                    count += f[j] + 1;
                    p++;
                }
            }
            if(count > s) continue;
            long C = nCr(s + n - 1 - count, n - 1);
            if(p % 2 == 1) C = -C;
            res += C;
        }

        System.out.println(res);
    }
}


import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;
import java.util.Vector;
public class Main {
	static final long mod=1000000007;
	public static void main(String[] args) {
		long a[]=new long[21];
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long s=sc.nextLong();
		for(int i=0;i<n;i++)
				a[i]=sc.nextLong();
		int len=(1<<n);
		long ans=0;
		for(int i=0;i<len;i++){
			long x=s;
			int flag=1;
			for(int j=0;j<len;j++)
				if(((i>>j)&1)==1){
					flag*=-1;
					x-=a[j]+1;
				}
			if(x<0)
				continue;
			ans=(ans+flag*lucas(x+n-1,n-1))%mod;
			ans=(ans+mod)%mod;
		}
		System.out.println(ans);
	}
	static long lucas(long a,long b){
		if(b==0)
			return 1;
		return getc(a%mod,b%mod)*lucas(a/mod,b/mod)%mod;
	}
	static long getc(long a,long b){
		if(a<b)
			return 0;
		long ans=1;
		for(long i=a-b+1;i<=a;i++)
			ans=ans*i%mod;
		long t=1;
		for(long i=1;i<=b;i++)
			t=t*i%mod;
		return ans*qpow(t,mod-2)%mod;
	}
	static long qpow(long a,long b){
		long ans=1;
		while(b!=0){
			if((b&1)==1){
				ans=a*ans%mod;
			}
			a=a*a%mod;
			b>>=1;
		}
		return ans;
	}
}


import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class CF {

    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        String ch = Integer.toHexString(n).toUpperCase();
        int s = 0;
        for (int i = 0; i < ch.length(); i++) {
            switch (ch.charAt(i)) {
                case '0':
                case '4':
                case '6':
                case '9':
                case 'A':
                case 'D':
                    s++;
                    break;
                case '8':
                case 'B':
                    s += 2;
                    break;
                default:
                    break;
            }
        }
        out.println(s);
        out.close();
    }

    public static int maxTab(int[] tab) {
        int max = 0;
        for (int i : tab) {
            max = max(i, max);
        }
        return max;
    }

    static class FastScanner {

        private BufferedReader in;
        private String[] line;
        private int index;
        private int size;

        public FastScanner(InputStream in) throws IOException {
            this.in = new BufferedReader(new InputStreamReader(in));
            init();
        }

        public FastScanner(String file) throws FileNotFoundException {
            this.in = new BufferedReader(new FileReader(file));
        }

        private void init() throws IOException {
            line = in.readLine().split(" ");
            index = 0;
            size = line.length;
        }

        public int nextInt() throws IOException {
            if (index == size) {
                init();
            }
            return Integer.parseInt(line[index++]);
        }

        public long nextLong() throws IOException {
            if (index == size) {
                init();
            }
            return Long.parseLong(line[index++]);
        }

        public float nextFloat() throws IOException {
            if (index == size) {
                init();
            }
            return Float.parseFloat(line[index++]);
        }

        public double nextDouble() throws IOException {
            if (index == size) {
                init();
            }
            return Double.parseDouble(line[index++]);
        }

        public String next() throws IOException {
            if (index == size) {
                init();
            }
            return line[index++];
        }

        public String nextLine() throws IOException {
            if (index == size) {
                init();
            }
            StringBuilder sb = new StringBuilder();
            for (int i = index; i < size; i++) {
                sb.append(line[i]).append(" ");
            }
            return sb.toString();
        }

        private int[] nextIntArray(int n) throws IOException {
            int[] tab = new int[n];
            for (int i = 0; i < tab.length; i++) {
                tab[i] = nextInt();
            }
            return tab;
        }

        private double[] nextDoubleArray(int n) throws IOException {
            double[] tab = new double[n];
            for (int i = 0; i < tab.length; i++) {
                tab[i] = nextDouble();
            }
            return tab;
        }

    }

}


import java.io.*;
import java.util.Arrays;

public class Main {
    static myScanner sc;
    static PrintWriter pw;

    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader input = new BufferedReader(new FileReader(new File("data.in")));
        sc = new myScanner(input);

        //pw = new PrintWriter(new File("data.out"));
        pw = new PrintWriter(System.out);

        solve();

        pw.flush();
        pw.close();
    }

    static void solve() {
        int n = sc.nextInt();
        String s = Integer.toString(n, 16).toUpperCase();
        int ans=0;
        for (int i=0;i<s.length();i++){
            switch (s.charAt(i)){
                case '4':
                case '6':
                case '9':
                case '0':
                case 'A':
                case 'D':{
                    ans+=1;
                    break;
                }
                case 'B':
                case '8':{
                    ans+=2;
                    break;
                }
            }
        }
        pw.print(ans);
    }
}

class myScanner {
    private char[] buffer = new char[1 << 8];
    private int pos = 1;

    private BufferedReader reader;

    public myScanner(BufferedReader reader) {
        this.reader = reader;
    }

    public boolean hasNext() {
        return pos > 0;
    }

    private void loadBuffer() {
        pos = 0;
        try {
            for (int i; (i = reader.read()) != -1; ) {
                char c = (char) i;
                if (c != ' ' && c != '\n' && c != '\t' && c != '\r' && c != '\f') {
                    if (pos == buffer.length) buffer = Arrays.copyOf(buffer, 2 * pos);
                    buffer[pos++] = c;
                } else if (pos != 0) break;
            }
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }

    public String current() {
        return String.copyValueOf(buffer, 0, pos);
    }

    public String next() {
        loadBuffer();
        return current();
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }

    public int nextInt() {
        return nextInt(10);
    }

    public long nextLong() {
        return nextLong(10);
    }

    public int nextInt(int radix) {
        loadBuffer();
        int result = 0;
        int i = buffer[0] == '-' || buffer[0] == '+' ? 1 : 0;
        for (checkValidNumber(pos > i); i < pos; i++) {
            int digit = buffer[i] - '0';
            checkValidNumber(0 <= digit && digit <= radix - 1);
            result = result * radix + digit;
        }
        return buffer[0] == '-' ? -result : result;
    }

    public long nextLong(int radix) {
        loadBuffer();
        long result = 0;
        int i = buffer[0] == '-' || buffer[0] == '+' ? 1 : 0;
        for (checkValidNumber(pos > i); i < pos; i++) {
            int digit = buffer[i] - '0';
            checkValidNumber(0 <= digit && digit <= radix - 1);
            result = result * radix + digit;
        }
        return buffer[0] == '-' ? -result : result;
    }

    public double nextDouble() {
        loadBuffer();
        double result = 0;
        int i = buffer[0] == '-' || buffer[0] == '+' ? 1 : 0;
        long round = 1;
        final int radix = 10;
        boolean hasPoint = false;
        for (checkValidNumber(pos > i); i < pos; i++) {
            int digit = buffer[i] - '0';
            checkValidNumber((0 <= digit && digit <= radix - 1) || (!hasPoint && digit == -2));
            if (digit == -2) hasPoint = true;
            else {
                if (hasPoint) round *= radix;
                result = result * radix + digit;
            }

        }
        return buffer[0] == '-' ? -result / round : result / round;
    }

    private void checkValidNumber(boolean condition) {
        if (!condition) throw new NumberFormatException(current());
    }
}


import  java.util.*;
public class ass {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in) ;
		System.out.println("2");
	}

}


package free1;
import java.util.*;
public class NumbersJoke {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in =  new Scanner(System.in) ;
		int n = in.nextInt() ;
		String hex  =	Integer.toHexString(n) ;
		hex =  hex.toUpperCase() ;
		char  c[] = hex.toCharArray();
		int cnt   =  0 ;

		for(int i  = 0 ; i<c.length  ; i++){
				 if(c[i] == '4' || c[i] ==  '6' || c[i] == '9' || c[i] == '0' || c[i] == 'A' || c[i] == 'D')
					 cnt ++ ;
				 else if(c[i] == '8' || c[i]  == 'B')
					 cnt +=2 ;

		}
		System.out.println(cnt);

	}

}


//package com.company;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        InputStreamReader input = new InputStreamReader(System.in);
        BufferedReader in = new BufferedReader(input);

        String s = in.readLine();
        String ss[] = s.split(" ");

        int n = Integer.parseInt(ss[0]);
        int k = Integer.parseInt(ss[1]);

        String number = in.readLine();
        if (k == 0)
        {
            System.out.println(number);
        }
        else if(n == 1 && k == 1)
        {
            System.out.println("0");
        }
        else
        {
            StringBuffer tmp = new StringBuffer("1");

            int a = k;
            if(number.charAt(0) != '1')
                a--;

            int zeros = 0;
            for(int i = 0; i < a; i++)
            {
                tmp.append('0');
                if(number.charAt(i) == '0')
                    zeros++;
            }

            if(number.length() - k + zeros > 0)
                tmp.append(number.substring(number.length() - k + zeros + 1));

            System.out.println(tmp.toString());
        }
    }
}


// Working program with FastReader
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.util.*;

public class Main {
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()){
				try{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine()  {
			String str = "";
			try{
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args) throws IOException {
		FastReader in=new FastReader();
		BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
		int n = in.nextInt();
		int k = in.nextInt();
		if(k > 0){
			char[] s = in.nextLine().toCharArray();

			if(s[0] != '1') {
				s[0] = '1';
				k--;
			}
			if(k == 0 ){
				s[0]= '0';
			}
			if(n == 1){
			    s[0]= '0';
			    k--;
			}

			for(int i = 1; i<=k && i<n; i++){
				if(s[i] == '0')
					k++;
				s[i]= '0';
			}

			log.write(new String(s));
		}else{
			log.write(in.nextLine());
		}

		log.flush();
		log.close();

	}
}


// Working program with FastReader
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedWriter;
import java.io.OutputStreamWriter;
import java.util.*;

public class Main {
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()){
				try{
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e){
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine()  {
			String str = "";
			try{
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args) throws IOException {
		FastReader in=new FastReader();
		BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
		int n = in.nextInt();
		int k = in.nextInt();
		if(k > 0){
			char[] s = in.nextLine().toCharArray();

			if(s[0] != '1') {
				s[0] = '1';
				k--;
			}
			if(k == 0)
				s[0]= '0';
			for(int i = 1; i<=k; i++){
				s[i]= '0';
			}

			log.write(new String(s));
		}else{
			log.write(in.nextLine());
		}

		log.flush();
		log.close();

	}
}


import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

public class myFile
{
	public static void main(String args[])
	{
	   Scanner sc = new Scanner(System.in);
	   int i,n,k;
	   while(sc.hasNextInt())
	   {
		   n = sc.nextInt();
		   k = sc.nextInt();
		   sc.nextLine();
		   String str = sc.nextLine();
		   if(n==1 && k==1)
		   {
			   System.out.println("0");
			   continue;
		   }
		   String ans="";
		   if(str.charAt(0)!='1')
			   k--;
		   ans+='1';
		   for(i=1;k>0 && i<str.length();i++)
		   {
			   ans+='0';
			   if(str.charAt(i)!='0')k--;
		   }
		   ans = ans+str.substring(i);
		   System.out.println(ans);
	   }

	}

}


import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Queue;
import java.util.Scanner;
import java.util.Set;
import java.util.concurrent.ArrayBlockingQueue;

public class ProblemC {
	static final long MOD = 1000000009;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = in.nextInt();
		int w = in.nextInt();
		int b = in.nextInt();

		long[][] dpGood = new long[n+2][w+2];
		long[][] dpBad = new long[n+2][b+2];
		dpGood[0][1] = w;
		for (int i = 0 ; i <= n ; i++) {
			for (int j = 1 ; j <= w ; j++) {
				if (dpGood[i][j] == 0) {
					continue;
				}
				long left = w - j;
				dpGood[i][j+1] += (dpGood[i][j] * left) % MOD;
				dpGood[i][j+1] %= MOD;

				dpGood[i+1][j+1] += (dpGood[i][j] * left) % MOD;
				dpGood[i+1][j+1] %= MOD;
			}
		}

		dpBad[0][1] = b;
		for (int i = 0 ; i <= n ; i++) {
			for (int j = 1 ; j <= b ; j++) {
				if (dpBad[i][j] == 0) {
					continue;
				}
				long left = b - j;
				dpBad[i][j+1] += (dpBad[i][j] * left) % MOD;
				dpBad[i][j+1] %= MOD;

				dpBad[i+1][j+1] += (dpBad[i][j] * left) % MOD;
				dpBad[i+1][j+1] %= MOD;
			}
		}

		long ans = 0;
		for (int baddays = 1 ; baddays <= n - 2 ; baddays++) {
			long pos = Math.max(0, n - baddays + 1 - 2);
			int gooddays = n - baddays;
			if (pos == 0) {
				break;
			}

			long add = pos * dpGood[gooddays-1][w];
			add %= MOD;
			add *= dpBad[baddays-1][b];
			add %= MOD;
			ans += add;
			ans %= MOD;
		}
		out.println(ans);
		out.flush();
	}

	public static void debug(Object... o) {
		System.err.println(Arrays.deepToString(o));
	}
}

/*

----========----
    ^      ^

1|2|3|4|5|6|7|8

*/


import java.io.*;
import java.util.*;

public class cf306c {
  static long mod = 1_000_000_009;
  public static void main(String[] args) {
    int MAX = 5000;
    long[][] calc = new long[MAX][MAX];
    for(int i=1; i<MAX; i++) {
      calc[i][0] = 1;
      for(int j=1; j<MAX; j++)
        calc[i][j] = (calc[i][j-1]*(i-j+1))%mod;
    }

    FastIO in = new FastIO(), out = in;
    int n = in.nextInt();
    int w = in.nextInt();
    int b = in.nextInt();

    long ans = 0;
    for(int bad = 1; bad <= Math.min(bad, n-2); bad++) {
      if(bad > b || (n-bad) > w) continue;
      long tmp = calc[b][bad];
      tmp = (tmp * calc[w][n-bad])%mod;
      tmp = (tmp * (n-bad-1)) % mod;
      ans = (ans+tmp)%mod;
    }
    out.println(ans);
    out.close();
  }
  static class FastIO extends PrintWriter {
    BufferedReader br;
    StringTokenizer st;

    public FastIO() {
      this(System.in, System.out);
    }

    public FastIO(InputStream in, OutputStream out) {
      super(new BufferedWriter(new OutputStreamWriter(out)));
      br = new BufferedReader(new InputStreamReader(in));
      scanLine();
    }

    public void scanLine() {
      try {
        st = new StringTokenizer(br.readLine().trim());
      } catch (Exception e) {
        throw new RuntimeException(e.getMessage());
      }
    }

    public int numTokens() {
      if (!st.hasMoreTokens()) {
        scanLine();
        return numTokens();
      }
      return st.countTokens();
    }

    public String next() {
      if (!st.hasMoreTokens()) {
        scanLine();
        return next();
      }
      return st.nextToken();
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }
  }
}


import java.io.*;
import java.util.*;

public class CFstupid {
    FastScanner in;
    PrintWriter out;

    long mod = (long) 1e9 + 9;

    void solve() {
       int n = in.nextInt();
       int w = in.nextInt();
       int b = in.nextInt();
       long ans = 0;
       int MAX = 8005;
       long[][] c = new long[MAX][MAX];
       c[0][0] = 1;
       for (int i = 1; i < MAX; i++) {
           c[i][0] = 1;
           for (int j = 1; j < MAX / 2; j++) {
               c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]);
               if (c[i][j] >= mod)
                   c[i][j] -= mod;
           }

       }
       for (int fr = 1; fr < n; fr++) {
           for (int to = fr; to < n - 1; to++) {
               if (to - fr + 1 <= b) {
                   int ost = n - (to - fr + 1);
                   if (ost <= w) {
                       long add = 1;
                       add = (add * c[w - 1][ost - 1]) % mod;
                       add = (add * c[b - 1][to - fr]) % mod;
                       ans += add;
                       ans %= mod;
                   }
               }
           }
       }
       for (int i = 1; i <= w; i++)
           ans = (ans * i) % mod;
       for (int i = 1; i <= b; i++)
           ans = (ans * i) % mod;
       out.println(ans);
    }

    void run() {
        try {
            in = new FastScanner(new File("test.in"));
            out = new PrintWriter(new File("test.out"));

            solve();

            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    void runIO() {

        in = new FastScanner(System.in);
        out = new PrintWriter(System.out);

        solve();

        out.close();
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(File f) {
            try {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        boolean hasMoreTokens() {
            while (st == null || !st.hasMoreTokens()) {
                String s = null;
                try {
                    s = br.readLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (s == null)
                    return false;
                st = new StringTokenizer(s);
            }
            return true;
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }

    public static void main(String[] args) {
        new CFstupid().runIO();
    }
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class WhiteBlackAndWhiteAgain {
	static long MOD = 1000000009;
	static long[] fac;
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int w = sc.nextInt();
		int b = sc.nextInt();

		fac = new long[n+1];
		fac[0] = 1;
		for(int i=1;i<fac.length;i++){
			fac[i] = (i* fac[i-1])%MOD;
		}
		long total = 0;
		for(int goodDays=2; goodDays<=n-1; goodDays++){
			int badDays = n-goodDays;
			if(goodDays > w || badDays >b){
				continue;
			}
			long badDaySplit = comb(b-1, badDays-1);
			long goodDaySplit = (comb(w-1, goodDays-1) * (goodDays-1))%MOD;
			total = (total + goodDaySplit*badDaySplit) %MOD;
		}
		total = (total*fac[w])%MOD;
		total = (total*fac[b])%MOD;
		System.out.println(total);
	}

	static long comb(int n, int k){
		BigInteger denom = BigInteger.valueOf((fac[n-k] *fac[k])%MOD);
		long inv = denom.modInverse(BigInteger.valueOf(MOD)).longValue();
		return (fac[n] * inv) % MOD;
	}

	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public final Rational ONE = new Rational(1, 1);
        public final Rational ZERO = new Rational(0, 1);

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int k = in.readInt();
            int pa = in.readInt();
            int pb = in.readInt();
            Rational probA = new Rational(pa, pa + pb);
            Rational probB = new Rational(pb, pa + pb);
            Rational[][] probAtState = new Rational[k + 1][2 * k]; // numA, ABPairAlready
            for (int row = 0; row < probAtState.length; row++) {
                for (int col = 0; col < probAtState[0].length; col++) {
                    probAtState[row][col] = ZERO;
                }
            }
            probAtState[1][0] = ONE;
            for (int numA = 1; numA < k; numA++) {
                for (int ABPairAlready = 0; ABPairAlready < k; ABPairAlready++) {
                    { // with chance pa / (pa + pb) we get an A here
                        probAtState[numA + 1][ABPairAlready] = probAtState[numA][ABPairAlready].multiply(probA);
                    }
                    { // with chance pb / (pa + pb) we get a B here
                        probAtState[numA][ABPairAlready + numA] = probAtState[numA][ABPairAlready + numA].add(probAtState[numA][ABPairAlready].multiply(probB));
                    }
                }
            }
            Rational res = ZERO;
            // Here we count num ABPairs where we have at least k AB pairs already
            for (int numA = 1; numA < probAtState.length; numA++) {
                for (int ABPairAlready = k; ABPairAlready < probAtState[0].length; ABPairAlready++) {
                    res = res.add(probAtState[numA][ABPairAlready].multiply(ABPairAlready));
                }
            }
            Rational expectMoreA = (probB.reverse()).subtract(ONE);
            for (int ABPairAlready = 0; ABPairAlready < k; ABPairAlready++) {
                // Now here we do not quite have the number of AB Pairs we need
                // but we have plenty of A already
                Rational nowA = expectMoreA.add(ABPairAlready).add(k);
                res = res.add(nowA.multiply(probAtState[k][ABPairAlready]));
            }
            out.printLine((long) res.numerator * IntegerUtils.reverse(res.denominator, MiscUtils.MOD7) % MiscUtils.MOD7);
        }

        public class Rational {
            long numerator;
            long denominator;

            public Rational(long numerator, long denominator) {
                if (denominator == 0) {
                    throw new IllegalArgumentException();
                }
                long gcd = IntegerUtils.gcd(Math.abs(numerator), Math.abs(denominator));
                if (denominator > 0) {
                    this.numerator = numerator / gcd;
                    this.denominator = denominator / gcd;
                } else {
                    this.numerator = -numerator / gcd;
                    this.denominator = -denominator / gcd;
                }
                this.numerator %= MiscUtils.MOD7;
                this.denominator %= MiscUtils.MOD7;
            }

            public Rational add(Rational other) {
                return new Rational(numerator * other.denominator + denominator * other.numerator,
                        denominator * other.denominator);
            }

            public Rational add(long other) {
                return new Rational(numerator + denominator * other,
                        denominator);
            }

            public Rational reverse() {
                if (numerator == 0) {
                    throw new ArithmeticException();
                }
                return new Rational(denominator, numerator);
            }

            public Rational multiply(long number) {
                return new Rational(numerator * number, denominator);
            }

            public Rational subtract(Rational other) {
                return new Rational(numerator * other.denominator - denominator * other.numerator,
                        denominator * other.denominator);
            }

            public Rational multiply(Rational other) {
                return new Rational(numerator * other.numerator, other.denominator * denominator);
            }
        }
    }
    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(long i) {
            writer.println(i);
        }
    }
    static class IntegerUtils {
        public static long gcd(long a, long b) {
            a = Math.abs(a);
            b = Math.abs(b);
            while (b != 0) {
                long temp = a % b;
                a = b;
                b = temp;
            }
            return a;
        }

        public static long power(long base, long exponent, long mod) {
            if (base >= mod) {
                base %= mod;
            }
            if (exponent == 0) {
                return 1 % mod;
            }
            long result = power(base, exponent >> 1, mod);
            result = result * result % mod;
            if ((exponent & 1) != 0) {
                result = result * base % mod;
            }
            return result;
        }

        public static long reverse(long number, long module) {
            return power(number, module - 2, module);
        }
    }
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
    static class MiscUtils {
        public static final int MOD7 = (int) (1e9 + 7);
    }
}


//package codeforces.GoodBye17;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class D
{
	static int mod = (int)1e9+7;
	static Pair[][] memo;
	static int a,b,k, a_b;
	static Pair sum1, pb, pa, sum2;
	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		k = sc.nextInt();
		a = sc.nextInt();
		b = sc.nextInt();
		a_b = sum(a, b);
		memo = new Pair[a+2][k+2];

		Pair one = new Pair(1, 1);
		pa = new Pair(a, a_b);
		pb = new Pair(b, a_b);
		sum1 = new Pair(one, one.subtract(pa));

		Pair one_pa = one.subtract(pa);
		Pair pp1 = new Pair(pa, one_pa);
		Pair pp2 = new Pair(one, one_pa);
		sum2 = pp1.multiply(pp2);

		Pair p = simplify(solve(1, 0));
		int rp = p.x;
		int rq = p.y;
		System.out.println(mult(rp, inv(rq, mod)));

		pw.flush();
		pw.close();
	}

	private static Pair simplify(Pair P)
	{
		int gcd = gcd(P.x, P.y);
		P.x = mult(P.x, inv(gcd, mod));
		P.y = mult(P.y, inv(gcd, mod));
		return P;
	}

	static int gcd(int a, int b)
	{
		if(b == 0)
			return a;
		return gcd(b, a%b);
	}

	static int sub(int a, int b)
	{
		int ans = a-b;
		ans %= mod;
		if(ans < 0)
			ans += mod;
		return ans;
	}

	private static Pair solve(int cntA, int tot)
	{
		if(tot >= k)
			return new Pair(tot, 1);
		if(cntA+tot >= k) // check > or >=
		{
			return pb.multiply(new Pair(tot+cntA, 1).multiply(sum1).add(sum2));
		}

		if(memo[cntA][tot] != null)
			return memo[cntA][tot];

		// a
		int num1 = mult(a, solve(cntA+1, tot).x);
		int den1 = mult(a_b, solve(cntA+1, tot).y);
		Pair a1 = new Pair(num1, den1);
		// b
		int num2 = mult(b, solve(cntA, tot+cntA).x);
		int den2 = mult(a_b, solve(cntA, tot+cntA).y);
		Pair a2 = new Pair(num2, den2);

		return memo[cntA][tot] = a1.add(a2);
	}

	static int mult(int a, int b)
	{
		return (int)(1l*a*b % mod);
	}

	static int sum(int a, int b)
	{
		return (a+b) % mod;
	}

	static class Pair
	{
		int x, y;

		public String toString()
		{
			return x +"/" + y;
		}
		public Pair(int x, int y)
		{
			this.x = x;
			this.y = y;
		}

		public Pair(Pair p1, Pair p2)
		{
			this.x = mult(p1.x, inv(p2.x, mod));
			this.y = mult(p1.y, inv(p2.y, mod));
		}

		Pair multiply(Pair p)
		{
			return new Pair(mult(x, p.x),  mult(y, p.y));
		}

		Pair add(Pair p)
		{
			int xy = mult(p.y, y);
			return new Pair(sum(mult(mult(xy, x), inv(y, mod)), mult(mult(p.x, xy), inv(p.y, mod))),  mult(y, p.y));
		}

		Pair subtract(Pair p)
		{
			Pair tmp = new Pair(-p.x, p.y);
			tmp.x %= mod;
			if(tmp.x < 0)
				tmp.x += mod;
			return add(tmp);
		}
	}

	static int inv(long  x , long mod){
		long r, y;
		for(r = 1 , y = mod - 2 ; y != 0 ;x = x * x % mod, y>>=1)
		if ((y & 1) == 1)
		r = r * x % mod;
		return (int)r;
		}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s)
		{
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String s) throws FileNotFoundException
		{
			br = new BufferedReader(new FileReader(new File((s))));
		}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException
		{
			return br.readLine();
		}

		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else
				{
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException
		{
			return br.ready();
		}
	}
}


//package codeforces.GoodBye17;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class D
{
	static int mod = (int)1e9+7;
	static int[][] memo;
	static int a,b,k, a_b;
	static int sum1, pb, pa, sum2;
	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);

		k = sc.nextInt();
		a = sc.nextInt();
		b = sc.nextInt();
		a_b = sum(a, b);
		memo = new int[k+2][k+2];
		for (int i = 0; i < a+2; i++)
			Arrays.fill(memo[i], -1);
		pa = mult(a, inv(a_b, mod));
		pb = mult(b, inv(a_b, mod));
		sum1 = mult(a+b, inv(b, mod));
		sum2 = mult(mult(a, a+b), inv(mult(b, b), mod));
		System.out.println(solve(1, 0));

		pw.flush();
		pw.close();
	}

	static int sub(int a, int b)
	{
		int ans = a-b;
		ans %= mod;
		if(ans < 0)
			ans += mod;
		return ans;
	}

	private static int solve(int cntA, int tot)
	{
		if(tot >= k)
			return tot;
		if(cntA >= k)
		{
			return memo[cntA][tot] = mult(pb, sum(mult(sum(tot, cntA), sum1), sum2));
			// pb * ((tot+cntA)(sum1) + sum2)
		}

		if(memo[cntA][tot] != -1)
			return memo[cntA][tot];

		// a
		int ans = mult(pa, solve(cntA+1, tot));
		// b
		ans = sum(ans, mult(pb, solve(cntA, tot+cntA)));

		return memo[cntA][tot] = ans;
	}

	static int mult(int a, int b)
	{
		return (int)(1l*a*b % mod);
	}

	static int sum(int a, int b)
	{
		return (a+b) % mod;
	}

	static int inv(long  x , long mod){
		long r, y;
		for(r = 1 , y = mod - 2 ; y != 0 ;x = x * x % mod, y>>=1)
		if ((y & 1) == 1)
		r = r * x % mod;
		return (int)r;
		}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s)
		{
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String s) throws FileNotFoundException
		{
			br = new BufferedReader(new FileReader(new File((s))));
		}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException
		{
			return br.readLine();
		}

		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else
				{
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException
		{
			return br.ready();
		}
	}
}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package d;

import java.io.*;
import java.util.*;

/**
 *
 * @author kamranmaharov
 */
public class Main {
    private static int k, pa, pb;
    private static int REM = 1000000007;

    private static class Quotient {
        private final int P, Q;

        Quotient(int P, int Q) {
            this.P = P;
            this.Q = inverse(Q);
        }

        public Quotient add(Quotient other) {
            return new Quotient(  (int)(((long)P*Q + (long)other.P*other.Q) % REM), 1);
        }

        public Quotient multiply(Quotient other) {
            return new Quotient((int)((long)P*Q%REM*other.P%REM*other.Q%REM), 1);
        }

        @Override
        public String toString() {
            return String.valueOf((long)P*Q % REM);
        }

        private static int inverse(int Q) {
            return pow(Q, REM-2);
        }

        private static int pow(int a, int b) {
            if (b==0) {return 1;}
            else if (b%2==1) {return (int)((long)pow(a,b-1) * a % REM);}
            else {
                int mid = pow(a,b/2);
                return (int)((long)mid*mid%REM);
            }
        }

        //private static int gcd(int a, int b) {
        //    return (b==0?a:gcd(b, a%b));
        //}
    }

    private static Quotient f(int c1, int c2) {
        if (c1+c2>=k) {
            return new Quotient(c1+c2, 1).add(new Quotient(pa, pb));
        } else {
            return f(c1, c2+1).multiply(new Quotient(pa, pa+pb)).add(
                    f(c1+c2, c2).multiply(new Quotient(pb, pa+pb)));
        }
    }

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));

        String[] line = in.readLine().split(" ");
        k = Integer.parseInt(line[0]);
        pa = Integer.parseInt(line[1]);
        pb = Integer.parseInt(line[2]);

        out.write(f(0, 1).toString() + "\n");
        out.close();
    }
}


import java.util.Scanner;

public class D {
    static final boolean DEBUG = false;

    static final int MOD = 1000000009;

    static int h = 0;

    static class State {
        int[][][] T;

        int[][][] F;

        State() {
            T = new int[h + 1][h + 1][h + 1];
            F = new int[h + 1][h + 1][h + 1];
        }

        void addStateT(int u, int v, int w, int number) {
            T[u][v][w] += number;
            T[u][v][w] %= MOD;
        }

        void addStateF(int u, int v, int w, int number) {
            F[u][v][w] += number;
            F[u][v][w] %= MOD;
        }

        int getStateT(int u, int v, int w) {
            return T[u][v][w];
        }

        int getStateF(int u, int v, int w) {
            return F[u][v][w];
        }

        int getTotal() {
            int total = 0;
            for (int u = 0; u <= h; u++) {
                for (int v = 0; v <= h; v++) {
                    for (int w = 0; w <= h; w++) {
                        if (u != h || v != h || w != h) {
                            total += getStateF(u, v, w);
                            total %= MOD;
                        }
                        total += getStateT(u, v, w);
                        total %= MOD;
                    }
                }
            }
            return total;
        }
    }

    static class Design {
        State curState;

        State newState;

        Design() {
            curState = new State();
            curState.addStateT(1, 1, 1, 4);
        }

        void createNewState() {
            newState = new State();
        }

        void commitNewState() {
            curState = newState;
        }

        void updateState(int u, int v, int w) {
            int nu = (u == h) ? h : u + 1;
            int nv = (v == h) ? h : v + 1;
            int nw = (w == h) ? h : w + 1;
            int t = curState.getStateT(u, v, w);
            int f = curState.getStateF(u, v, w);
            newState.addStateT(nu, nv, nw, t);
            newState.addStateF(nu, nv, nw, f);
            if (u == h) {
                newState.addStateF(1, nv, nw, t);
                newState.addStateF(nv, nw, h, f);
            } else {
                newState.addStateT(1, nv, nw, t);
                newState.addStateT(nv, nw, h, f);
            }
            if (v == h) {
                newState.addStateF(1, nu, nw, t);
                newState.addStateF(nu, nw, h, f);
            } else {
                newState.addStateT(1, nu, nw, t);
                newState.addStateT(nu, nw, h, f);
            }
            if (w == h) {
                newState.addStateF(1, nu, nv, t);
                newState.addStateF(nu, nv, h, f);
            } else {
                newState.addStateT(1, nu, nv, t);
                newState.addStateT(nu, nv, h, f);
            }
        }

        void nextState() {
            createNewState();
            for (int u = 0; u <= h; u++) {
                for (int v = 0; v <= h; v++) {
                    for (int w = 0; w <= h; w++) {
                        updateState(u, v, w);
                    }
                }
            }
            commitNewState();
        }

        int getTotal() {
            int total = 0;
            for (int i = 0; i < 4; i++) {
                total = (total + curState.getTotal()) % D.MOD;
            }
            return total;
        }
    }

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        h = s.nextInt();
        if (h == 1) {
            System.out.println(4);
            return;
        }

        long start = System.currentTimeMillis();

        Design design = new Design();
        for (int i = 1; i < n; i++) {
            design.nextState();
        }

        System.out.println(design.getTotal());

        if (DEBUG) {
            System.out.println(System.currentTimeMillis() - start);
        }
    }
}


import java.util.*;

public class D{
	static final int MOD = 1000000009;
	static int increment(int last, int h){
		if (last == 0){
			return 0;
		}
		return (last + 1)%h;
	}
	static int boolean2int(boolean in){
		return in ? 1 : 0;
	}
	public static void main(String [] args){
		try (Scanner s = new Scanner(System.in)){
			final int n = s.nextInt();
			final int h = s.nextInt();
			final long [][][][][] dp = new long[2][2][32][32][32];
			dp[1][1][0][0][0] = 4;
			int p = 1;
			for (int i = 1; i <= n - 1; ++i){
				for (int alive = 0; alive <= 1; ++alive){
					for (int last1 = 0; last1 < h; ++last1){
						for (int last2 = 0; last2 < h; ++last2){
							for (int last3 = 0; last3 < h; ++last3){
								final int a = increment(last1, h);
								final int b = increment(last2, h);
								final int c = increment(last3, h);
								final int alive1 = boolean2int(i < h || last1 > 0);
								final int alive2 = boolean2int(i < h || last2 > 0);
								final int alive3 = boolean2int(i < h || last3 > 0);
								dp[(p + 1)%2][alive][a][b][c] += dp[p][alive][last1][last2][last3];
								dp[(p + 1)%2][alive][a][b][c] %= MOD;

								dp[(p + 1)%2][alive1][alive][b][c] += dp[p][alive][last1][last2][last3];
								dp[(p + 1)%2][alive1][alive][b][c] %= MOD;

								dp[(p + 1)%2][alive2][a][alive][c] += dp[p][alive][last1][last2][last3];
								dp[(p + 1)%2][alive2][a][alive][c] %= MOD;

								dp[(p + 1)%2][alive3][a][b][alive] += dp[p][alive][last1][last2][last3];
								dp[(p + 1)%2][alive3][a][b][alive] %= MOD;
							}
						}
					}
				}
				for (int alive = 0; alive <= 1; ++alive){
					for (int last1 = 0; last1 < h; ++last1){
						for (int last2 = 0; last2 < h; ++last2){
							for (int last3 = 0; last3 < h; ++last3){
								dp[p][alive][last1][last2][last3] = 0;
							}
						}
					}
				}
				p = (p + 1)%2;
			}
			long res = 0;
			for (int last1 = 0; last1 < h; ++last1){
				for (int last2 = 0; last2 < h; ++last2){
					for (int last3 = 0; last3 < h; ++last3){
						res += dp[p][1][last1][last2][last3];
						if (last1 + last2 + last3 > 0){
							res += dp[p][0][last1][last2][last3];
						}
						res %= MOD;
					}
				}
			}

			System.out.println(res);
		}
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt(), M = in.nextInt() + 1;
            int[][][][] dp = new int[M][M][M][2];

            dp[0][0][0][1] = 1;

            final int Mod = (int) (1e9 + 9);

            for (int i = 0; i < N; ++i) {
                int[][][][] ndp = new int[M][M][M][2];
                for (int j = 0; j < M; ++j) {
                    for (int k = 0; k < M; ++k) {
                        for (int p = 0; p < M; ++p) {
                            for (int u = 0; u < 2; ++u) {
                                int add = dp[j][k][p][u];

                                int nj, nk, np, nu;
                                np = u == 1 ? 1 : M - 1;

                                nj = Math.min(k + 1, M - 1);
                                nk = Math.min(p + 1, M - 1);
                                nu = j < M - 1 ? 1 : 0;

                                ndp[nj][nk][np][nu] += add;
                                ndp[nj][nk][np][nu] %= Mod;

                                nj = Math.min(j + 1, M - 1);
                                nk = Math.min(p + 1, M - 1);
                                nu = k < M - 1 ? 1 : 0;

                                ndp[nj][nk][np][nu] += add;
                                ndp[nj][nk][np][nu] %= Mod;

                                nj = Math.min(j + 1, M - 1);
                                nk = Math.min(k + 1, M - 1);
                                nu = p < M - 1 ? 1 : 0;

                                ndp[nj][nk][np][nu] += add;
                                ndp[nj][nk][np][nu] %= Mod;

                                nk = Math.min(k + 1, M - 1);
                                nj = Math.min(j + 1, M - 1);
                                np = Math.min(p + 1, M - 1);
                                nu = u;

                                ndp[nj][nk][np][nu] += add;
                                ndp[nj][nk][np][nu] %= Mod;
                            }
                        }
                    }
                }

                dp = ndp;
            }

            int ans = 0;
            for (int i = 0; i < M; ++i)
                for (int j = 0; j < M; ++j)
                    for (int k = 0; k < M; ++k)
                        for (int u = 0; u < 2; ++u)
                            if (i < M - 1 || j < M - 1 || k < M - 1 || u == 1)
                                ans = (ans + dp[i][j][k][u]) % Mod;

            out.println(ans);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}


/*
 * Author Ayub Subhaniya
 * Institute DA-IICT
 */

import java.io.*;
import java.math.*;
import java.util.*;

public class Codeforces429B
{

	InputStream in;
	PrintWriter out;

	void solve()
	{
		int n=ni();
		int k=ni();
		int m=ni();
		int a=ni();
		Pair votes[]=new Pair[n];
		for (int i=0;i<n;i++)
			votes[i]=new Pair(0,0,i);

		for (int i=1;i<=a;i++)
		{
			int cand=ni()-1;
			votes[cand].i=i;
			votes[cand].c++;
		}

		Arrays.sort(votes);

		int remV=m-a;
		int r[]=new int[n];

		if (n==k)
		{
			if (a==m)
				for (int i=0;i<n;i++)
					if (votes[i].c>0)
						r[votes[i].idx]=1;
					else
						r[votes[i].idx]=3;
			else
				for (int i=0;i<n;i++)
						r[votes[i].idx]=1;
		}
		else
		{
			for (int i=0;i<k;i++)
			{
				int sum=0;
				for (int j=i+1;j<=k;j++)
					sum+=votes[i].c-votes[j].c+1;
				//tr(votes[i].idx+" "+sum+" "+remV);
				if (sum>remV)
					r[votes[i].idx]=1;
				else
					r[votes[i].idx]=2;
			}

			for (int i=k;i<n;i++)
			{
				int req=votes[k-1].c-votes[i].c+1;
				//tr(votes[i].idx+" "+req+" "+remV);
				if (req<=remV)
					r[votes[i].idx]=2;
				else
					r[votes[i].idx]=3;
			}
		}

		for (int i:r)
			out.print(i+" ");

	}

	class Pair implements Comparable<Pair> {
		int idx;
		int i;
		int c;
		Pair(int a, int b, int i) {
			this.i = a;
			c = b;
			idx = i;
		}

		@Override
		public int compareTo(Pair o) {
			if (c == o.c)
				return Integer.compare(i, o.i);
			else
				return Integer.compare(o.c, c);
		}
	}

	void run() throws Exception
	{
		String INPUT = "C:/Users/ayubs/Desktop/input.txt";
		in = oj ? System.in : new FileInputStream(INPUT);
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis() - s + "ms");

	}
	public static void main(String[] args) throws Exception
	{
		new Codeforces429B().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf)
		{
			ptrbuf = 0;
			try
			{
				lenbuf = in.read(inbuf);
			}
			catch (IOException e)
			{
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean inSpaceChar(int c)
	{
		return !(c >= 33 && c <= 126);
	}

	private int skip()
	{
		int b;
		while ((b = readByte()) != -1 && inSpaceChar(b))
			;
		return b;
	}

	private double nd()
	{
		return Double.parseDouble(ns());
	}

	private char nc()
	{
		return (char) skip();
	}

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(inSpaceChar(b)))
		{ // when nextLine, (inSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(inSpaceChar(b)))
		{
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-')
		{
			minus = true;
			b = readByte();
		}

		while (true)
		{
			if (b >= '0' && b <= '9')
			{
				num = num * 10 + (b - '0');
			}
			else
			{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-')
		{
			minus = true;
			b = readByte();
		}

		while (true)
		{
			if (b >= '0' && b <= '9')
			{
				num = num * 10 + (b - '0');
			}
			else
			{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private void tr(Object... o)
	{
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}

}


import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.lang.Math;
import java.math.BigInteger;
import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;

// CODEFORCES
public class main {

	static int cycleNum;

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int k = scanner.nextInt();
		int m = scanner.nextInt();
		int a = scanner.nextInt();
		int[] voted = new int[a];
		for (int i = 0; i < a; i++) {
		    voted[i] = scanner.nextInt();
		}
//		int[][] ts = new int[k][2];
//		int[] cols = new int[q];
//
//		String[] s1 = scanner.nextLine().split(" ");
//		for (int i = 0; i < k; i++) {
//		    s1 = scanner.nextLine().split(" ");
//		    ts[i][0] = Integer.valueOf(s1[0]);
//		    ts[i][1] = Integer.valueOf(s1[1]);
//		}
//		s1 = scanner.nextLine().split(" ");
//		for (int i = 0; i < q; i++) {
//		    cols[i] = Integer.valueOf(s1[i]);
//		}
//		Arrays.sort(cols);
//
//		String[] s1 = new String[n];
//		String [] s2 = new String[n];
//
//		s1 = scanner.nextLine().split(" ");
//		s2 = scanner.nextLine().split(" ");

//		scanner = new Scanner(System.in);
//		String[] s = scanner.nextLine().split(" ");

//	String[] str1 = new String[4];
//		str1 = scanner.nextLine().split(" ");
//		String[] str2 = new String[Integer.valueOf(str1[0])];
//		while(scanner.hasNextLine()){
//			str2 = scanner.nextLine().split(" ");
//		}

//		int[] p = new int[n];
//		int[] q = new int[n];
//		for (int i = 0; i < s1.length; i++) {
//			p[i] = Integer.valueOf(s1[i]);
//			q[i] = Integer.valueOf(s2[i]);
//		}

// 		int n = 3;
// 		int k = 1;
// 		int m = 5;
// 		int a = 4;
// 		int[] voted = {1,2,1,3};
		HashMap<Integer, int[]> cMap = new HashMap<>();
		ArrayList<Integer> zeroVotes = new ArrayList<>();
		for (int i = 1; i <= n; i++) {
			zeroVotes.add(i);
		}
		for (int i = 0; i < voted.length; i++) {
			if (cMap.containsKey(voted[i])) {
				 cMap.get(voted[i])[0] += 1;
				 cMap.get(voted[i])[1] = i;
			} else {
				zeroVotes.remove(new Integer(voted[i]));
				int[] t = {1, i};
				cMap.put(voted[i], t);
			}
		}

		HashMap<Integer, int[]> sortedCMap = sortMap(cMap);
		int[][] cArr = new int[n+1][2]; // Candidate number, number of votes
		int ind = 1;
		for (Map.Entry<Integer, int[]> entry : sortedCMap.entrySet()) {
			cArr[ind][0] = entry.getKey();
			cArr[ind][1] = entry.getValue()[0];
			ind += 1;
		}

		ind = 0;
		for (int i = 1; i < cArr.length; i++) {
			if (cArr[i][0] == 0) {
				cArr[i][0] = zeroVotes.get(ind);
				cArr[i][1] = 0;
				ind += 1;
			}
		}

		int minTopK = (int)Math.pow(10, 6);
		HashMap<Integer, Integer> topK = new HashMap<>();
		for (int i = 1; i <= k; i++) {
			topK.put(cArr[i][0], 1);
			minTopK = Math.min(minTopK, cArr[i][1]);
		}

		int[] answers = new int[n+1];
		for (int i = 1; i < answers.length; i++) {

			// Check 1
			if (topK.containsKey(i)) {
				int p = find(cArr, i);
				ind = p+1;
				int cnt = 0;
				int sum = 0;
				while (ind < cArr.length && cnt < k-p+1) {
					sum += cArr[p][1]+1 - cArr[ind][1];
					ind += 1;
					cnt += 1;
				}
				//if (i == 1) { System.out.println(cnt); }
				if (cnt == k-p+1 && sum > m-a) {
					answers[i] = 1;
				}
			}
			// Check 3
			if (answers[i] == 0 && !topK.containsKey(i)) {
				int p = find(cArr, i);
				if (m-a+cArr[p][1] <= minTopK) {
					answers[i] = 3;
				}
			}
			// Check 2
			if (answers[i] == 0) {
				answers[i] = 2;
			}

		}

//		for (int i = 0; i < cArr.length; i++) {
//			System.out.println(Arrays.toString(cArr[i]));
//		}

		for (int i = 1; i < answers.length; i++) {
			System.out.print(answers[i] + " ");
		}

	}

	static int find(int[][] cArr, int cNum) {
		int ans = 0;
		for (int i = 1; i < cArr.length; i++) {
			if (cArr[i][0] == cNum) {
				ans = i;
				break;
			}
		}
		return ans;
	}

	static HashMap<Integer, int[]> sortMap(HashMap<Integer, int[]> cMap) {
		List<Map.Entry<Integer, int[]>> list = new LinkedList<Map.Entry<Integer, int[]>>(cMap.entrySet());
		Collections.sort(list, new Comparator<Map.Entry<Integer, int[]>>() {
			public int compare(Map.Entry<Integer, int[]> a, Map.Entry<Integer, int[]> b) {
				if (a.getValue()[0] > b.getValue()[0]) {
					return 1;
				} else if (a.getValue()[0] == b.getValue()[0]) {
					if (a.getValue()[1] < b.getValue()[1]) { return 1;}
					else { return -1; }
				} else {
					return -1;
				}
			}
		});

		Collections.reverse(list);
		HashMap<Integer, int[]> temp = new LinkedHashMap<>();
		for (Map.Entry<Integer, int[]> x : list) {
			temp.put(x.getKey(), x.getValue());
		}
		return temp;
	}

//H*(H+1)/2 + (x-H)*H >= n
// ((y.multiply(y.add(BigInteger.ONE))).divide(BigInteger.TWO).add((x2.subtract(y)).multiply(y))).compareTo(n2) >= 0
// (x2.subtract(y)).multiply(y)

}

//List sortedKeys=new ArrayList(trip.keySet());
//Collections.sort(sortedKeys);


import java.io.*;
import java.util.*;
import java.util.Map.Entry;
import java.lang.Math;
import java.math.BigInteger;
import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;

// CODEFORCES
public class main {

	static int cycleNum;

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int k = scanner.nextInt();
		int m = scanner.nextInt();
		int a = scanner.nextInt();
		int[] voted = new int[a];
		for (int i = 0; i < a; i++) {
		    voted[i] = scanner.nextInt();
		}
//		int[][] ts = new int[k][2];
//		int[] cols = new int[q];
//
//		String[] s1 = scanner.nextLine().split(" ");
//		for (int i = 0; i < k; i++) {
//		    s1 = scanner.nextLine().split(" ");
//		    ts[i][0] = Integer.valueOf(s1[0]);
//		    ts[i][1] = Integer.valueOf(s1[1]);
//		}
//		s1 = scanner.nextLine().split(" ");
//		for (int i = 0; i < q; i++) {
//		    cols[i] = Integer.valueOf(s1[i]);
//		}
//		Arrays.sort(cols);
//
//		String[] s1 = new String[n];
//		String [] s2 = new String[n];
//
//		s1 = scanner.nextLine().split(" ");
//		s2 = scanner.nextLine().split(" ");

//		scanner = new Scanner(System.in);
//		String[] s = scanner.nextLine().split(" ");

//	String[] str1 = new String[4];
//		str1 = scanner.nextLine().split(" ");
//		String[] str2 = new String[Integer.valueOf(str1[0])];
//		while(scanner.hasNextLine()){
//			str2 = scanner.nextLine().split(" ");
//		}

//		int[] p = new int[n];
//		int[] q = new int[n];
//		for (int i = 0; i < s1.length; i++) {
//			p[i] = Integer.valueOf(s1[i]);
//			q[i] = Integer.valueOf(s2[i]);
//		}

// 		int n = 3;
// 		int k = 1;
// 		int m = 5;
// 		int a = 4;
// 		int[] voted = {1,2,1,3};
		HashMap<Integer, int[]> cMap = new HashMap<>();
		ArrayList<Integer> zeroVotes = new ArrayList<>();
		for (int i = 1; i <= n; i++) {
			zeroVotes.add(i);
		}
		for (int i = 0; i < voted.length; i++) {
			if (cMap.containsKey(voted[i])) {
				 cMap.get(voted[i])[0] += 1;
				 cMap.get(voted[i])[1] = i;
			} else {
				zeroVotes.remove(new Integer(voted[i]));
				int[] t = {1, i};
				cMap.put(voted[i], t);
			}
		}

		HashMap<Integer, int[]> sortedCMap = sortMap(cMap);
		int[][] cArr = new int[n+1][2]; // Candidate number, number of votes
		int ind = 1;
		for (Map.Entry<Integer, int[]> entry : sortedCMap.entrySet()) {
			cArr[ind][0] = entry.getKey();
			cArr[ind][1] = entry.getValue()[0];
			ind += 1;
		}

		ind = 0;
		for (int i = 1; i < cArr.length; i++) {
			if (cArr[i][0] == 0) {
				cArr[i][0] = zeroVotes.get(ind);
				cArr[i][1] = 0;
				ind += 1;
			}
		}

		int minTopK = (int)Math.pow(10, 6);
		HashMap<Integer, Integer> topK = new HashMap<>();
		for (int i = 1; i <= k; i++) {
		    if (cArr[i][1] == 0) {
				continue;
			}
			topK.put(cArr[i][0], 1);
			minTopK = Math.min(minTopK, cArr[i][1]);
		}

		int[] answers = new int[n+1];
		for (int i = 1; i < answers.length; i++) {

			int p = find(cArr, i);

			// Check 1
			if (topK.containsKey(i)) {
				ind = p+1;
				int cnt = 0;
				int sum = 0;
				while (ind < cArr.length && cnt < k-p+1) {
					sum += cArr[p][1]+1 - cArr[ind][1];
					ind += 1;
					cnt += 1;
				}
				//if (i == 1) { System.out.println(cnt); }
				if (cnt < k-p+1 || sum > m-a) {
					answers[i] = 1;
				}
			}
			// Check 3
			if (answers[i] == 0 && !topK.containsKey(i)) {
				if (m-a+cArr[p][1] <= minTopK) {
					answers[i] = 3;
				}
			}
			// Check 2
			if (answers[i] == 0) {
				answers[i] = 2;
			}

		}

//		for (int i = 0; i < cArr.length; i++) {
//			System.out.println(Arrays.toString(cArr[i]));
//		}

		for (int i = 1; i < answers.length; i++) {
			System.out.print(answers[i] + " ");
		}

	}

	static int find(int[][] cArr, int cNum) {
		int ans = 0;
		for (int i = 1; i < cArr.length; i++) {
			if (cArr[i][0] == cNum) {
				ans = i;
				break;
			}
		}
		return ans;
	}

	static HashMap<Integer, int[]> sortMap(HashMap<Integer, int[]> cMap) {
		List<Map.Entry<Integer, int[]>> list = new LinkedList<Map.Entry<Integer, int[]>>(cMap.entrySet());
		Collections.sort(list, new Comparator<Map.Entry<Integer, int[]>>() {
			public int compare(Map.Entry<Integer, int[]> a, Map.Entry<Integer, int[]> b) {
				if (a.getValue()[0] > b.getValue()[0]) {
					return 1;
				} else if (a.getValue()[0] == b.getValue()[0]) {
					if (a.getValue()[1] < b.getValue()[1]) { return 1;}
					else { return -1; }
				} else {
					return -1;
				}
			}
		});

		Collections.reverse(list);
		HashMap<Integer, int[]> temp = new LinkedHashMap<>();
		for (Map.Entry<Integer, int[]> x : list) {
			temp.put(x.getKey(), x.getValue());
		}
		return temp;
	}

//H*(H+1)/2 + (x-H)*H >= n
// ((y.multiply(y.add(BigInteger.ONE))).divide(BigInteger.TWO).add((x2.subtract(y)).multiply(y))).compareTo(n2) >= 0
// (x2.subtract(y)).multiply(y)

}

//List sortedKeys=new ArrayList(trip.keySet());
//Collections.sort(sortedKeys);


//package neerc2017;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;

public class F {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni(), K = ni(), m = ni(), A = ni();
		int[] a = na(A);
		for(int i = 0;i < A;i++)a[i]--;
		int[] f = new int[n];
		int[] last = new int[n];
		Arrays.fill(last, -1);
		for(int i = 0;i < A;i++){
			f[a[i]]++;
			last[a[i]] = i;
		}
		for(int i = 0;i < n;i++){
			int flag = 0;
			{
				int[] lf = Arrays.copyOf(f, n);
				int[] llast = Arrays.copyOf(last, n);
				lf[i] += m-A;
				if(m-A > 0)llast[i] = m-1;
				flag |= ok(lf, llast, K, i) ? 2 : 0;
			}
			{
				int[][] fl = new int[n-1][];
				int p = 0;
				for(int j = 0;j < n;j++){
					if(j == i)continue;
					fl[p++] = new int[]{f[j], last[j], j};
				}
				Arrays.sort(fl, new Comparator<int[]>() {
					public int compare(int[] a, int[] b) {
						if(a[0] != b[0])return -(a[0] - b[0]);
						return a[1] - b[1];
					}
				});

				int[] lf = Arrays.copyOf(f, n);
				int[] llast = Arrays.copyOf(last, n);
				int rem = m-A;
				for(int j = 0;j < n-1;j++){
					int fv = fl[j][0], lv = fl[j][1];
					if(fv > lf[i] || fv == lf[i] && lv < llast[i])continue;
					int up = Math.min(rem, lf[i]+1-fv);
					rem -= up;
					lf[fl[j][2]] += up;
					llast[fl[j][2]] = n-1;
				}
				flag |= ok(lf, llast, K, i) ? 1 : 0;
			}
			if(flag == 3){
				out.print(1 + " ");
			}else if(flag == 2){
				out.print(2 + " ");
			}else if(flag == 0){
				out.print(3 + " ");
			}else{
				throw new RuntimeException();
			}
		}
	}

	boolean ok(int[] f, int[] last, int K, int who)
	{
		if(f[who] == 0)return false;
		int n = f.length;
		int rank = 1;
		for(int i = 0;i < n;i++){
			if(i == who)continue;
			if(f[i] > f[who] || f[i] == f[who] && last[i] < last[who])rank++;
		}
		return rank <= K;
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception { new F().run(); }

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Pixels {

    /**
     * @param args
     */
    public static void main(String[] args) {
        BufferedReader inpt = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer input;
        long n = 0;
        try {
            input = new StringTokenizer(inpt.readLine());
            long[] rgb = {Integer.parseInt(input.nextToken()),Integer.parseInt(input.nextToken()),Integer.parseInt(input.nextToken())};
            descendingSort(rgb);
            while(rgb[1]!=0){
                if(rgb[2] != 0){
                    n = n+rgb[2];
                    rgb[0] = rgb[0] + rgb[2];
                    rgb[1] = rgb[1] - rgb[2];
                    rgb[2] = 0;
                } else if(rgb[1] == 1) {
                    n = n+rgb[0];
                    rgb[1] = 0;
                    rgb[0] = 0;
                    rgb[2] = 1;
                } else {
                    n = n+rgb[1]/2;
                    rgb[0] = rgb[0] - rgb[1]/2;
                    rgb[2] = rgb[2] + rgb[1]/2;
                    rgb[1] = rgb[1] - rgb[1]/2;
                }
                descendingSort(rgb);
                //System.out.println(rgb[0] +" "+rgb[1]+" "+rgb[2]);
            }

            if(rgb[0] == 0){
                n = -1;
            }
            System.out.println(n);

        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    public static void descendingSort(long[] a){
        Arrays.sort(a);
        long c = a[0];
        a[0] = a[2];
        a[2] = c;
    }

}


import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Pixels {

    /**
     * @param args
     */
    public static void main(String[] args) {
        BufferedReader inpt = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer input;
        int n = 0;
        try {
            input = new StringTokenizer(inpt.readLine());
            int[] rgb = {Integer.parseInt(input.nextToken()),Integer.parseInt(input.nextToken()),Integer.parseInt(input.nextToken())};
            descendingSort(rgb);
            while(rgb[1]!=0){
                if(rgb[2] != 0){
                    n = n+rgb[2];
                    rgb[0] = rgb[0] + rgb[2];
                    rgb[1] = rgb[1] - rgb[2];
                    rgb[2] = 0;
                } else if(rgb[1] == 1) {
                    n = n+rgb[0];
                    rgb[1] = 0;
                    rgb[0] = 0;
                    rgb[2] = 1;
                } else {
                    n = n+rgb[1]/2;
                    rgb[0] = rgb[0] - rgb[1]/2;
                    rgb[2] = rgb[2] + rgb[1]/2;
                    rgb[1] = rgb[1] - rgb[1]/2;
                }
                descendingSort(rgb);
                System.out.println(rgb[0] +" "+rgb[1]+" "+rgb[2]);
            }

            if(rgb[0] == 0){
                n = -1;
            }
            System.out.println(n);

        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    public static void descendingSort(int[] a){
        Arrays.sort(a);
        int c = a[0];
        a[0] = a[2];
        a[2] = c;
    }

}


import java.util.Scanner;

public class Pixel {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int i,j,k,n,a,b,c,big,middle,small,sum;
        while (input.hasNext()){
            a = input.nextInt(); b = input.nextInt(); c = input.nextInt(); sum = 0;

            big = (a>=b) ? ((a>=c)? a :c) : ((b>=c) ? b : c);
            small = (a>=b) ? ((b>=c) ? c : b) : ((a>=c) ? c : a);
            middle = a>b ? (c>a ? a :(b>c)? b:c) : (c>b ? b : a>c? a : c);

           // System.out.println(big+ " " + middle + " " + small);
            for (i=0; i<big; i++){
                if (big == middle || big == small || middle == small) break;
                if ((middle - small ) % 2 == 0){
                    big--;middle--;small++; sum++;
                }
                else break;
            }

            if (big == middle) sum += big;
            else if (big == small) sum += big;
            else if (small == middle) sum += small;
            else sum+=big;
            System.out.println(sum);
        }
    }
}