import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class TwoSets<V> {

    private static int n;

    private static int a;

    private static int b;

    private static List<Node<Integer>> nodes = new LinkedList<Node<Integer>>();

    private static Map<Integer, Node<Integer>> datas = new HashMap<Integer, Node<Integer>>();

    private static Node<Integer> first;

    private static Node<Integer> second;

    private static TwoSets<Integer> sets = new TwoSets<Integer>();

    private static class Node<V> {

	V node;

	Node<V> parent;

	int rank;

	int color = -1;

	boolean inprogress;

	public Node() {
	    this.parent = this;
	}

	@Override
	public String toString() {
	    return String.format("{node: %s, parent: %s, rank: %s, color:%s}",
		    node, parent.node, rank, color);
	}
    }

    public Node<V> makeSet(V x) {

	Node<V> node = new Node<V>();

	node.node = x;
	node.parent = node;
	node.rank = 0;

	return node;
    }

    public void link(Node<V> x, Node<V> y) {

	if (x.rank > y.rank) {
	    y.parent = x;
	} else {
	    x.parent = y;
	    if (x.rank == y.rank) {
		y.rank++;
	    }
	}
    }

    public Node<V> findSet(Node<V> x) {

	if (x.parent != x) {
	    x.parent = findSet(x.parent);
	}

	return x.parent;
    }

    public void union(Node<V> x, Node<V> y) {

	Node<V> rtX = findSet(x);
	Node<V> rtY = findSet(y);
	if (rtX.parent != rtY.parent) {
	    link(rtX, rtY);
	}
    }

    public V getNode(Node<V> x) {
	return x.node;
    }

    private int getColor(Node<V> node) {

	int color;
	Node<V> parent = findSet(node);
	color = parent.color;

	return color;
    }

    private void setColor(Node<V> node, int color) {
	Node<V> parent = findSet(node);
	parent.color = color;
    }

    private static Node<Integer> getOrInitNode(Integer key) {

	Node<Integer> node = datas.get(key);

	if (node == null) {
	    node = sets.makeSet(key);
	    datas.put(key, node);
	}

	return node;
    }

    private static void initNodes(Scanner scanner) {

	int key;
	Node<Integer> node;
	for (int i = 0; i < n; i++) {
	    key = scanner.nextInt();
	    node = getOrInitNode(key);
	    nodes.add(node);
	}
    }

    private static void unionAll(Node<Integer> value) {

	int color = sets.getColor(value);
	if (color == 0) {
	    if (first == null) {
		first = value;
	    } else {
		sets.union(first, value);
	    }
	} else if (color == 1) {
	    if (second == null) {
		second = value;
	    } else {
		sets.union(second, value);
	    }
	}
    }

    private static int getKey(Node<Integer> value, int color) {

	int key = value.node;

	if (color == 0) {
	    key = a - key;
	} else {
	    key = b - key;
	}

	return key;
    }

    private static boolean checkOpposite(Node<Integer> value, int color) {

	boolean valid;

	if (value.inprogress) {
	    valid = Boolean.TRUE;
	} else {
	    value.inprogress = Boolean.TRUE;
	    int opColor = 1 - color;
	    int key = getKey(value, opColor);
	    Node<Integer> node = datas.get(key);
	    valid = (value.node.equals(key)) || (node == null);
	    if (!valid) {
		key = getKey(node, color);
		Node<Integer> child = datas.get(key);
		valid = (child != null);
		if (valid) {
		    valid = checkOpposite(child, color);
		    if (valid) {
			sets.union(value, node);
			sets.union(value, child);
			value.inprogress = Boolean.FALSE;
		    }
		}
	    }
	    value.inprogress = Boolean.FALSE;
	}

	return valid;
    }

    private static boolean checkNodes(Node<Integer> value, int color) {

	boolean valid;

	int key = getKey(value, color);
	int opColor = 1 - color;
	Node<Integer> node = datas.get(key);
	valid = (value.node.equals(key)) || (node != null);
	if (valid) {
	    valid = checkOpposite(value, color);
	    if (valid) {
		sets.union(value, node);
		sets.setColor(value, color);
	    } else if (color == 0) {
		valid = checkNodes(value, opColor);
	    }
	} else if (color == 0) {
	    valid = checkNodes(value, opColor);
	}

	return valid;
    }

    private static void format(StringBuilder builder, int i) {

	if (i > 0) {
	    builder.append(' ');
	}
    }

    private static String printNodes() {

	String text;

	StringBuilder builder = new StringBuilder();
	Iterator<Node<Integer>> iterator = nodes.iterator();
	int i = 0;
	Node<Integer> node;
	while (iterator.hasNext()) {
	    format(builder, i);
	    node = iterator.next();
	    builder.append(sets.getColor(node));
	    i++;
	}
	text = builder.toString().trim();

	return text;
    }

    private static boolean checkNodes(int color) {

	boolean valid = Boolean.TRUE;

	for (Node<Integer> value : nodes) {
	    if (sets.getColor(value) == -1) {
		valid = checkNodes(value, color);
		if (valid) {
		    unionAll(value);
		} else {
		    break;
		}
	    }
	}

	return valid;
    }

    private static void calculate() {

	int color = 0;
	boolean valid = checkNodes(color);
	String message = "NO";
	if (valid) {
	    message = "YES";
	    String array = printNodes();
	    System.out.println(message);
	    System.out.println(array);
	} else {
	    System.out.println(message);
	}
    }

    public static void main(String[] args) {

	Scanner scanner = new Scanner(System.in);
	try {
	    n = scanner.nextInt();
	    a = scanner.nextInt();
	    b = scanner.nextInt();
	    initNodes(scanner);
	    calculate();
	} finally {
	    scanner.close();
	}
    }
}


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

public class Main {
    private static StringTokenizer st;
    private static BufferedReader br;
    public static long MOD = 1000000007;
    public static long tenFive = 100000;
    public static int INF = 100000;

    public static void print(Object x) {
        System.out.println(x + "");
    }
    public static void printArr(long[] x) {
        StringBuilder s = new StringBuilder();
        for (int i = 0; i < x.length; i++) {
            s.append(x[i] + " ");
        }
        print(s);
    }
    public static void printArr(int[] x) {
        StringBuilder s = new StringBuilder();
        for (int i = 0; i < x.length; i++) {
            s.append(x[i] + " ");
        }
        print(s);
    }
    public static String join(Collection<?> x, String space) {
        if (x.size() == 0) return "";
        StringBuilder sb = new StringBuilder();
        boolean first = true;
        for (Object elt : x) {
            if (first) first = false;
            else sb.append(space);
            sb.append(elt);
        }
        return sb.toString();
    }

    public static String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            String line = br.readLine();
            st = new StringTokenizer(line.trim());
        }
        return st.nextToken();
    }
    public static int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public static List<Integer> nextInts(int N) throws IOException {
        List<Integer> ret = new ArrayList<Integer>();
        for (int i = 0; i < N; i++) {
            ret.add(nextInt());
        }
        return ret;
    }

    public static void solve(int a, int b, List<Integer> orig) {
        boolean swap = false;
        if (a > b) {
            swap = true;
            int tmp = a;
            a = b;
            b = tmp;
        }

        List<Integer> nums = new ArrayList<Integer>(orig);
        Collections.sort(nums);
        Collections.reverse(nums);

        Set<Integer> all = new HashSet<Integer>(nums);
        Set<Integer> done = new HashSet<Integer>();
        Set<Integer> inB = new HashSet<Integer>();
        for (int x : nums) {
            if (done.contains(x)) continue;
            if (all.contains(a - x) && !done.contains(a - x)) {
                done.add(x);
                done.add(a - x);
                //print(x + " " + (a - x));
            } else if (all.contains(b - x) && !done.contains(b - x)) {
                done.add(x);
                done.add(b - x);
                inB.add(x);
                inB.add(b - x);
            } else {
                print("NO");
                return;
            }
        }

        print("YES");
        List<Integer> out = new ArrayList<Integer>();
        for (int x : orig) {
            if (inB.contains(x) ^ swap) out.add(1);
            else out.add(0);
        }
        print(join(out, " "));
    }

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

        int n = nextInt();
        int a = nextInt();
        int b = nextInt();
        List<Integer> nums = nextInts(n);
        solve(a, b, nums);
    }
}


import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main2 {

	static List<List<Integer>> getLayers(int[] numbers, int a, int b) {
		boolean[] used = new boolean[numbers.length];
		HashSet<Integer> hs = new HashSet<Integer>();
		for (int i = 0; i < numbers.length; i++) {
			hs.add(numbers[i]);
		}
		HashMap<Integer, Integer> numberToIndex = new HashMap<Integer, Integer>();
		for (int i = 0; i < numbers.length; i++) {
			numberToIndex.put(numbers[i], i);
		}

		List<List<Integer>> ans = new ArrayList<List<Integer>>();
		for (int i = 0; i < numbers.length; i++) {
			if (!used[i]) {

				List<Integer> ansRow = new ArrayList<Integer>();
				LinkedList<Integer> current = new LinkedList<Integer>();
				current.add(numbers[i]);
				while (!current.isEmpty()) {
					int c = current.removeFirst();
					used[numberToIndex.get(c)] = true;

					boolean found = false;

					if (hs.contains(a - c)) {
						found = true;
						if (a - c != c)
							current.add(a - c);
					}

					if (hs.contains(b - c)) {
						found = true;
						if (b - c != c)
							current.add(b - c);
					}

					if (found || ansRow.size() > 0)
						ansRow.add(c);

					hs.remove(c);
				}

				ans.add(ansRow);
			}
		}

		return ans;
	}

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

		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int[] numbers = new int[n];
		for (int i = 0; i < numbers.length; i++) {
			numbers[i] = sc.nextInt();
		}

		HashSet<Integer> hs = new HashSet<Integer>();
		for (int i = 0; i < numbers.length; i++) {
			hs.add(numbers[i]);
		}

		int[] belongs = new int[n];
		for (int i = 0; i < belongs.length; i++) {
			belongs[i] = -1;
		}

		HashMap<Integer, Integer> numberToIndex = new HashMap<Integer, Integer>();
		for (int i = 0; i < numbers.length; i++) {
			numberToIndex.put(numbers[i], i);
		}

		boolean possible = true;

		List<List<Integer>> layers = getLayers(numbers, a, b);
		for (List<Integer> layer : layers) {

			if (layer.size() == 0) {
				System.out.println("NO");
				return;
			}

			int starting = -1;
			for (int j = 0; j < layer.size(); j++) {
				int cur = layer.get(j);

				int nei = 0;
				if (hs.contains(a - cur)) {
					nei++;
				}

				if (hs.contains(b - cur)) {
					nei++;
				}

				if (nei == 1 || (a == b && nei == 2)) {
					starting = j;
				}
			}

			if (starting == -1)
				throw new Error();

			int c = layer.get(starting);
			HashSet<Integer> layerset = new HashSet<Integer>(layer);
			while (true) {

				if (layerset.contains(c) && layerset.contains(a - c)) {
					belongs[numberToIndex.get(c)] = 0;
					belongs[numberToIndex.get(a - c)] = 0;
					layerset.remove(c);
					layerset.remove(a - c);
					c = b - (a - c);
				} else if (layerset.contains(c) && layerset.contains(b - c)) {
					belongs[numberToIndex.get(c)] = 1;
					belongs[numberToIndex.get(b - c)] = 1;
					layerset.remove(c);
					layerset.remove(b - c);
					c = a - (b - c);
				} else {
					break;
				}

			}
		}

		printResult(belongs);

	}

	static void printResult(int[] belongs) {

		boolean ok = true;
		for (int i = 0; i < belongs.length; i++) {
			if (belongs[i] < 0)
				ok = false;
		}

		if (ok) {
			System.out.println("YES");
			StringBuffer sb = new StringBuffer();

			for (int i = 0; i < belongs.length; i++) {
				sb.append(belongs[i]);
				if (i != belongs.length - 1)
					sb.append(" ");
			}

			System.out.println(sb.toString());
		} else {
			System.out.println("NO");
		}
	}

}


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

public class B {

    void solve() throws IOException {
        int n=nextInt();
        int a=nextInt();
        int b=nextInt();
        int[] p=new int[n];
        for(int i=0;i<n;i++)p[i]=nextInt();
//        if(n%2==1){
//            out.println("NO");
//            return;
//        }
        TreeSet<Integer>[] s=new TreeSet[n];
        for(int i=0;i<n;i++)s[i]=new TreeSet<Integer>();
        HashMap<Integer,Integer> m=new HashMap<Integer, Integer>();
        for(int i=0;i<n;i++)
            m.put(p[i],i);
        for(int i=0;i<n;i++){
            if(m.containsKey(a-p[i])){
                s[i].add(a-p[i]);
                s[m.get(a-p[i])].add(p[i]);
            }
            if(m.containsKey(b-p[i])){
                s[i].add(b-p[i]);
                s[m.get(b-p[i])].add(p[i]);
            }
        }
        int last=-1;
        LinkedList<Integer> q=new LinkedList<Integer>();
        for(int i=0;i<n;i++){
            if(s[i].size()==0){
                out.println("NO");
                return;
            }
            if(s[i].size()==1){
                q.add(i);
            }
        }
        int[] ans=new int[n];
        while(last!=n){
            while(!q.isEmpty()){
                int cur=q.poll();
                if(s[cur].size()==0)continue;
                int x=p[cur];
                int y=s[cur].first();
                if(x==a-y){
                    ans[cur]=1;
                    ans[m.get(y)]=1;
                }
                else{
                    ans[cur]=2;
                    ans[m.get(y)]=2;
                }
                for(Integer u:s[m.get(y)]){
                    int o=m.get(u);
                    if(o!=m.get(y)) {
                        s[o].remove(y);
                        if (s[o].size() == 1) q.add(o);
                    }
                }
                for(Integer u:s[cur]){
                    int o=m.get(u);
                    if(o!=m.get(y)) {
                        s[o].remove(y);
                        if (s[o].size() == 1) q.add(o);
                    }
                }
            }
            last++;
            while(last!=n){
                if(s[last].size()!=0&&ans[last]==0)break;
                last++;
            }
            if(last!=n){
                q.add(last);
            }
        }
        for(int i=0;i<n;i++)
            if(ans[i]==0){
                out.println("NO");
                return;
            }
        out.println("YES");
        for(int i=0;i<n;i++)
            out.print((ans[i]-1)+" ");
    }

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

    void run() throws IOException {
        reader = new BufferedReader(new InputStreamReader(System.in));
//      reader = new BufferedReader(new FileReader("input.txt"));
        tokenizer = null;
        out = new PrintWriter(new OutputStreamWriter(System.out));
//      out = new PrintWriter(new FileWriter("output.txt"));
        solve();
        reader.close();
        out.flush();

    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter out;

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

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

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

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}


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

public class Main {

	BufferedReader in;
	StringTokenizer str = null;
	PrintWriter out;

	private String next() throws Exception{
		while (str == null || !str.hasMoreElements())
			str = new StringTokenizer(in.readLine());
		return str.nextToken();
	}

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

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

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

	Map<Integer, Integer> map;
	int []p, rank;

	public void run() throws Exception{
		in =  new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		map = new HashMap<Integer, Integer>();

		int n = nextInt();
		int x = nextInt(), y = nextInt();
		int []a = new int[n];
		p = new int[n];
		for(int i = 1; i < n; ++i) p[i] = i;
		rank = new int[n];

		for(int i = 0; i < n; ++i) {
			a[i] = nextInt();
			map.put(a[i], i);
		}
		int mask[] = new int[n];
		for(int i = 0; i < n; ++i) {
			if (map.containsKey(x - a[i])) {
				union(map.get(x - a[i]), i);
				mask[i] |= 1;
			}
			if (map.containsKey(y - a[i])) {
				union(map.get(y - a[i]), i);
				mask[i] |= 2;
			}
		}

		int []b = new int[n];
		Arrays.fill(b, 3);
		for(int i = 0; i < n; ++i) b[find(i)] &= mask[i];
		for(int i = 0; i < n; ++i) {
			if (b[i] == 0) {
				out.println("NO");
				out.close();
				return;
			}
		}

		out.println("YES");
		for(int i = 0; i < n; ++i) {
			out.print((b[find(i)] & 1) == 1 ? 0 : 1);
			if (i != n - 1) out.print(" ");
		}
		out.println();
		out.close();
	}

	private int find(int x) {
		if (x != p[x])
			return p[x] = find(p[x]);
		return x;
	}
	private void union(int a, int b) {
		a = find(a);
		b = find(b);
		if (rank[a] < rank[b]) {
			int tmp = a;
			a = b;
			b = tmp;
		}
		p[b] = a;
		if (rank[a] == rank[b]) ++rank[a];
	}

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


import java.util.Map;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.TreeMap;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

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

class TaskB {
    int n, a, b;
    Map<Integer, Integer> position;
    int[] p;
    int[] group;

    public void solve(int testNumber, FastInputReader in, PrintWriter out) {
        n = in.nextInt();
        a = in.nextInt();
        b = in.nextInt();

        position = new TreeMap<Integer, Integer>();
        p = new int[n];
        group = new int[n];

        for (int i = 0; i < n; i++) {
            p[i] = in.nextInt();
            group[i] = -1;
            position.put(p[i], i);
        }

        for (int i = 0; i < n; i++) {
            if (getMate(i) != -1)
                continue;
            out.println("NO");
            return;
        }

        for (int i = 0; i < n; i++) {
            boolean aMate = position.containsKey(a - p[i]);
            boolean bMate = position.containsKey(b - p[i]);
            if (aMate && bMate)
                continue;
            if (group[i] != -1)
                continue;
            if (!solve(i)) {
                out.println("NO");
                return;
            }
        }

        for (int i = 0; i < n; i++) {
            if (group[i] != -1)
                continue;
            if (!solve(i)) {
                out.println("NO");
                return;
            }
        }

        out.println("YES");
        for (int i = 0; i < n; i++) {
            out.print(group[i]);
            out.print(" ");
        }
        out.println();
    }

    private boolean solve(int index) {
        int mate = getMate(index);
        if (mate == -1)
            return false;
        assign(index, mate);
        if (getMate(index) != -1)
            return solve(getMate(index));
        else
            return getMate(mate) == -1 || solve(getMate(mate));
    }

    private void assign(int index, int mate) {
        int sum = p[index] + p[mate];
        if (sum == a) {
            group[index] = group[mate] = 0;
            return;
        }
        if (sum == b) {
            group[index] = group[mate] = 1;
            return;
        }
        throw new RuntimeException("Wrong assignment :(");
    }

    private int getMate(int index) {
        int[] possibleMates = new int[] {a - p[index], b - p[index]};
        for (int mate: possibleMates) {
            if (position.containsKey(mate)) {
                int mateIndex = position.get(mate);
                if (group[mateIndex] == -1)
                    return mateIndex;
            }
        }
        return -1;
    }
}

class FastInputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public FastInputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

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

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


import java.util.Map;
import java.io.IOException;
import java.util.InputMismatchException;
import java.util.TreeMap;
import java.io.PrintStream;
import java.io.OutputStream;
import java.util.ArrayDeque;
import java.io.PrintWriter;
import java.util.Deque;
import java.math.BigInteger;
import java.util.Queue;
import java.util.Collection;
import java.io.InputStream;

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

class TaskB
{
    int val[];
    int p[];
    int aneigh[], bneight[], deg[];
    Deque<Integer> mycycle;
    boolean loops = false;
    public void solve(int testNumber, FastReader in, PrintWriter out)
    {
        int n = in.ni ();
        val = new int[n];
        int a = in.ni ();
        int b = in.ni ();
        Map<Integer, Integer> set = new TreeMap<Integer, Integer> ();
        p = in.iArr (n);
        for (int i = 0; i < n; i++)
        {
            set.put (p[i], i);
        }
        aneigh = new int[n];
        bneight = new int[n];
        deg = new int[n];
        for (int i = 0; i < n; i++)
        {
            aneigh[i] = val[i] = bneight[i] = -1;
            deg[i] = 0;
        }
        Queue<Integer> queue = new ArrayDeque<Integer> ();
        for (int i = 0; i < n; i++)
        {
            Integer x1 = set.get (a - p[i]);
            Integer x2 = set.get (b - p[i]);
            if (x1 != null)
            {
                aneigh[i] = x1;
                deg[i]++;
            }
            if (x2 != null && a != b)
            {
                bneight[i] = x2;
                deg[i]++;
            }
            if (deg[i] == 1)
            {
                queue.add (i);
            }
        }

        while (!queue.isEmpty ())
        {
            int idx = queue.remove ();
            if (deg[idx] != 1)
            {
                continue;
            }
            int aa = aneigh[idx];
            int bb = bneight[idx];
            if (aa != -1)
            {
                val[idx] = val[aa] = 0;
                deg[aa]--;
                deg[idx]--;
                aneigh[aa] = -1;
                aneigh[idx] = -1;
                if (deg[aa] == 1)
                {
                    int zz = bneight[aa];
                    bneight[zz] = -1;
                    deg[zz]--;
                    if(deg[zz] == 1)
                    queue.add (zz);
                }
            }
            else
            {
                val[idx] = val[bb] = 1;
                deg[bb]--;
                deg[idx]--;
                bneight[idx] = bneight[bb] = -1;
                if (deg[bb] == 1)
                {
                    //queue.add (bb);
                    int zz = aneigh[bb];
                    aneigh[zz] = -1;
                    deg[zz]--;
                    if(deg[zz] == 1)
                        queue.add (zz);
                }
            }
        }

        for (int i = 0; i < n; i++)
        {
            if (val[i] == -1 && cantBePaired(i))
            {
                out.println ("NO");
                return;
            }
        }

        //every person has two neighbours

        //cases => either cycles or linear path with loops end points
        for (int i = 0; i < n; i++)
        {
            if (val[i] == -1)
            {
                mycycle = new ArrayDeque<Integer> ();
                loops = false;
                cycle (i);
                if (loops || mycycle.size () % 2 == 0)
                {
                    doEvenCycle ();
                    continue;
                }

                out.println ("NO");
                return;
            }
        }
        out.println ("YES");
        for (int i = 0; i < n; i++)
        {
            out.print (val[i] + " ");
        }
        out.println ();
    }

    private boolean cantBePaired(int i)
    {
        int aa = aneigh[i];
        int bb = bneight[i];
        if (aa != -1 && val[aa] == -1)
        {
            return false;
        }
        if (bb != -1 && val[bb] == -1)
        {
            return false;
        }
        return true;
    }

    private void doEvenCycle()
    {
        for (int x : mycycle)
        {
            val[x] = 0;
        }
    }

    private void cycle(int i)
    {
        boolean aa = false;
        int prev = i;
        mycycle.addLast (i);
        System.out.println (i);
        int j = aneigh[i];
        while (j != i)
        {
            if (j == prev)
            {
                loops = true;
                break;
            }
            mycycle.addLast (j);
            System.out.println (j);
            prev = j;
            j = aa ? aneigh[j] : bneight[j];
//            if (j == -1)
//            {
//                System.out.println (prev + " " + aneigh[prev] + bneight[prev] + " " + deg[prev] + " " + val[prev] + " " + val[64] + " " + deg[64]);
//            }
            aa = !aa;
        }

        if (loops)
        {
            j = bneight[i];
            prev = i;
            aa = true;
            while (prev != j)
            {
                mycycle.addFirst (j);

                prev = j;
                j = aa ? aneigh[j] : bneight[j];
                aa = !aa;
            }
        }
        System.out.println ("XXX");
    }
}

class FastReader
{

    public InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private SpaceCharFilter filter;

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

    public FastReader()
    {

    }

    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 ni()
    {
        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 int[] iArr(int n)
    {
        int a[] = new int[n];
        for (int i = 0; i < n; i++)
        {
            a[i] = ni ();
        }
        return a;
    }

    public interface SpaceCharFilter
    {
        public boolean isSpaceChar(int ch);
    }
}


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	int work(int x){
		if(x%2==0)return x+1;
		else return x-1;
	}
	static int N = 200050;
	class Node implements Comparable <Node>{
		int x, id;
		Node(int x, int id){
			this.x = x; this.id = id;
		}
		public int compareTo(Node o){
			return Integer.compare(x, o.x);
		}
		public String toString(){
			return id + "=" + x;
		}
	}
	class Edge{
		int from, to, nex;
		Edge (int from, int to, int nex){
			this.from = from;
			this.to = to;
			this.nex = nex;
		}
	}
	Edge[] edge = new Edge[N*10];
	int[] head = new int[N];
	int edgenum;
	void addedge(int u, int v){
	    Edge E = new Edge(u, v, head[u]);
	    edge[edgenum] = E;
	    head[u] = edgenum ++;
	}

	int n;
	int[] p = new int[N], ans = new int[N];
	int a, b, max;
    Map<Integer, Integer> map = new HashMap();
    boolean match(int x, int y, int col){
    	int P = map.get(x);
    	if(map.containsKey(y-x) == false)
    		return false;
    	int Q = map.get(y - x);
    	if(ans[Q] == -1 || x * 2 == y){
    		ans[Q] = ans[P] = col;
    	}
    	else {
    		if(match(a+b-2*y+x, y, col))
    			ans[Q] = ans[P] = col;
    		else return false;
    	}
    	return true;
    }
    boolean solve(){
    	if(max >= a && max >= b)return false;
    	for(int i = 1; i <= n; i++)
    		if(ans[i] == -1)
    		{
    			if(match(p[i], a, 0)==false && match(p[i], b, 1) == false)
    				return false;
    		}
    	return true;
    }
	void init(){
		n = cin.nextInt();
		a = cin.nextInt(); b = cin.nextInt();
		max = 0;
		for(int i = 1; i <= n; i++){
			ans[i] = -1;
			p[i] = cin.nextInt();
			map.put(p[i], i);
			if(p[i] > max) max = p[i];
		}
	}
	public void work(){
		init();
		if(solve()){
			out.println("YES");
			for(int i = 1; i <= n; i++)out.print(ans[i]+" "); out.println();
		}
		else
			out.println("NO");
	}
	Main() {
        cin = new Scanner(System.in);
        out = new PrintWriter(System.out);
    }
    public static void main(String[] args) {
        Main e = new Main();
        e.work();
        out.close();
    }
    public Scanner cin;
    public static PrintWriter out;
}


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

public class Main {

	static BufferedReader reader;
	static StringTokenizer tokenizer;
	static PrintWriter writer;

	static int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	static long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(nextToken());
	}

	static double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}

	static String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	public static void main(String[] args) throws IOException {
		reader = new BufferedReader(new InputStreamReader(System.in));
		writer = new PrintWriter(System.out);
		pineapple();
		reader.close();
		writer.close();
	}

	static void pineapple() throws NumberFormatException, IOException {
		int n = nextInt();
		int a = nextInt();
		int b = nextInt();
		TreeSet<Integer> al = new TreeSet<Integer>();
		TreeMap<Integer, Integer> mp = new TreeMap<Integer, Integer>();
		int[] ans = new int[n];
		Arrays.fill(ans, -1);
		TreeSet<Integer> used = new TreeSet<Integer>();
		int[] mas = new int[n];

		for (int i = 0; i < n; i++) {
			int t = nextInt();
			al.add(t);
			mas[i] = t;
			mp.put(t, i);
		}

		for (int st : al) {
			if (used.contains(st))
				continue;

			{
				int pr = st;
				int cc = -1;
				TreeSet<Integer> u2 = new TreeSet<Integer>();
				u2.add(pr);
				if (al.contains(a - pr) && !u2.contains(a - pr))
					cc = a - pr;
				else if (al.contains(b - pr) && !u2.contains(a - pr))
					cc = b - pr;
				if (cc != -1) {
					u2.add(cc);
					boolean bGo = true;
					while (bGo) {
						bGo = false;
						int nxt = -1;
						if (al.contains(a - cc) && !u2.contains(a - cc))
							nxt = a - cc;
						else if (al.contains(b - cc) && !u2.contains(b - cc))
							nxt = b - cc;
						if (nxt != -1) {
							bGo = true;
							u2.add(nxt);
							cc = nxt;
							pr = cc;
						}
					}
					st = cc;
				}
			}

			int x = st;
			while (x != -1) {
				int curr = x;
				used.add(curr);
				x = -1;
				int next1 = a - curr;
				if (al.contains(next1)) {
					if (!used.contains(next1)) {
						x = next1;
						int ci = mp.get(curr);
						int ni = mp.get(next1);
						if (ans[ci] == -1 && ans[ni] == -1) {
							ans[ni] = 0;
							ans[ci] = 0;
						}
					}
				}
				int next2 = b - curr;
				if (al.contains(next2)) {
					if (!used.contains(next2)) {
						x = next2;
						int ci = mp.get(curr);
						int ni = mp.get(next2);
						if (ans[ci] == -1 && ans[ni] == -1) {
							ans[ni] = 1;
							ans[ci] = 1;
						}
					}
				}
			}
		}

		for (int i = 0; i < n; i++) {
			if (ans[i] == -1) {
				if (2 * mas[i] == a) {
					ans[i] = 0;
					continue;
				}
				if (2 * mas[i] == b) {
					ans[i] = 1;
					continue;
				}
				writer.println("NO");
				return;
			}
		}

		writer.println("YES");
		for (int i = 0; i < n; i++) {
			writer.print(ans[i] + " ");
		}
	}
}


import java.util.*;
import java.util.Map.Entry;
import java.io.*;

public class A{

    public static void main(String args[]){
        FastScanner in = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        boolean change = false;
        if(a > b){
            int t = a;
            a = b;
            b = t;
            change = true;
        }
        boolean[] inb = new boolean[n];
        int[] numbers = new int[n];
        TreeMap<Integer, Integer> num = new TreeMap<Integer, Integer>();
        for(int i = 0; i < n; i++){
            num.put(in.nextInt(), i);
        }
        boolean hasAns = true;
        while(!num.isEmpty()){
            Entry<Integer, Integer> last = num.lastEntry();
            int key = last.getKey();
            if(num.containsKey(a - key)){
                num.remove(key);
                num.remove(a - key);
            } else if(num.containsKey(b - key)){
                inb[num.get(key)] = true;
                inb[num.get(b - key)] = true;
                num.remove(key);
                num.remove(b - key);
            } else{
                hasAns = false;
                break;
            }
        }
        if(hasAns){
            out.println("YES");
            for(int i = 0; i < n && !change; i++){
                if(inb[i]){
                    out.print("1");
                } else{
                    out.print("0");
                }
                if(i != n - 1){
                    out.print(" ");
                }
            }
            for(int i = 0; i < n && change; i++){
                if(inb[i]){
                    out.print("0");
                } else{
                    out.print("1");
                }
                if(i != n - 1){
                    out.print(" ");
                }
            }
        } else{
            out.println("NO");
        }
        out.close();
    }

    static class FastScanner{
        private BufferedReader reader;

        private StringTokenizer tokenizer;

        public FastScanner(InputStream stream){
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String nextLine(){
            try{
                return reader.readLine();
            } catch(IOException e){
                e.printStackTrace();
                return null;
            }
        }

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

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

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

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


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	int work(int x){
		if(x%2==0)return x+1;
		else return x-1;
	}
	static int N = 200050;
	class Node implements Comparable <Node>{
		int x, id;
		Node(int x, int id){
			this.x = x; this.id = id;
		}
		public int compareTo(Node o){
			return Integer.compare(x, o.x);
		}
		public String toString(){
			return id + "=" + x;
		}
	}
	class Edge{
		int from, to, nex;
		Edge (int from, int to, int nex){
			this.from = from;
			this.to = to;
			this.nex = nex;
		}
	}
	Edge[] edge = new Edge[N*10];
	int[] head = new int[N];
	int edgenum;
	void addedge(int u, int v){
	    Edge E = new Edge(u, v, head[u]);
	    edge[edgenum] = E;
	    head[u] = edgenum ++;
	}

	int n;
	int[] p = new int[N], ans = new int[N];
	int a, b, max;
    Map<Integer, Integer> map = new HashMap();
    boolean match(int x, int y, int col){
    	int P = map.get(x);
    	if(map.containsKey(y-x) == false)
    		return false;
    	int Q = map.get(y - x);
    	if(ans[Q] == -1 || x * 2 == y){
    		ans[Q] = ans[P] = col;
    	}
    	else {
    		if(match(a+b-2*y+x, y, col))
    			ans[Q] = ans[P] = col;
    		else return false;
    	}
    	return true;
    }
    boolean solve(){
    	if(max >= a && max >= b)return false;
    	for(int i = 1; i <= n; i++)
    		if(ans[i] == -1)
    		{
    			if(match(p[i], a, 0)==false && match(p[i], b, 1) == false)
    				return false;
    		}
    	return true;
    }
	void init(){
		n = cin.nextInt();
		a = cin.nextInt(); b = cin.nextInt();
		max = 0;
		for(int i = 1; i <= n; i++){
			ans[i] = -1;
			p[i] = cin.nextInt();
			map.put(p[i], i);
			if(p[i] > max) max = p[i];
		}
	}
	public void work(){
		init();
		if(solve()){
			out.println("YES");
			for(int i = 1; i <= n; i++)out.print(ans[i]+" "); out.println();
		}
		else
			out.println("NO");
	}
	Main() {
        cin = new Scanner(System.in);
        out = new PrintWriter(System.out);
    }
    public static void main(String[] args) {
        Main e = new Main();
        e.work();
        out.close();
    }
    public Scanner cin;
    public static PrintWriter out;
}
/*
http://blog.csdn.net/keshuai19940722/article/details/39528801

*/


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;
import static java.lang.Integer.*;

public class BDiv1 {
static int n;
static int a;
static int b;
static HashMap<Integer,Integer> graphA=new HashMap<>();
static HashMap<Integer,Integer> graphB=new HashMap<>();
static int [] array;
static int [] original;
static boolean x=true;

    public static void main(String[] args) throws Exception{
        BufferedReader buf =new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st =new StringTokenizer(buf.readLine());
        n=parseInt(st.nextToken());
        a=parseInt(st.nextToken());
        b=parseInt(st.nextToken());
        st =new StringTokenizer(buf.readLine());
        array=new int[n];
        original=new int [n];
        for (int i=0;i<n;i++){
            array[i]=parseInt(st.nextToken());
            original[i]=array[i];
        }
        Arrays.sort(array);
for (int i=0;i<n;i++){
    int k= Arrays.binarySearch(array,a-array[i]);
    if (k>=0){
        graphA.put(array[i],array[k]);
        graphA.put(array[k],array[i]);
    }
}
for (int i=0;i<n;i++){
    int k= Arrays.binarySearch(array,b-array[i]);
    if (k>=0){
        graphB.put(array[i],array[k]);
        graphB.put(array[k],array[i]);
    }
    }

for (int i=0;i<n;i++){
    Integer j=graphA.get(array[i]);
    if (j!=null){
        if (graphB.containsKey(array[i]) && graphB.containsKey(j)){
            graphA.remove(array[i]);
            graphA.remove(j);
        }
        else if (graphB.containsKey(array[i]) && !graphB.containsKey(j)){

            graphB.remove(graphB.get(array[i]));
            graphB.remove(array[i]);
        }
        else if (!graphB.containsKey(array[i]) && graphB.containsKey(j)){
            graphB.remove(graphB.get(j));
            graphB.remove(j);
        }

    }

}

int [] res=new int [n];
for (int i=0;i<n;i++){
    if (graphA.containsKey(original[i]))res[i]=0;
    else if (graphB.containsKey(original[i])) res[i]=1;
    else {
        System.out.println("NO");
        return;
    }
}
System.out.println("YES");
for (int k:res)System.out.print(k+" ");
}

    }


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

public class Main {
  // main
  public static void main(String [] args) throws IOException {
    // makes the reader and writer
    BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));

    // read in n,a,b,ints
    StringTokenizer st = new StringTokenizer(f.readLine());
    int n = Integer.parseInt(st.nextToken());
    int a = Integer.parseInt(st.nextToken());
    int b = Integer.parseInt(st.nextToken());
    st = new StringTokenizer(f.readLine());
    HashMap<Integer,Integer> in = new HashMap<Integer,Integer>();
    int[][] locs = new int[n][2];
    for (int i=0;i<n;i++) {
      int num = Integer.parseInt(st.nextToken());
      locs[i] = new int[]{num,i};
      in.put(num,i);
    }

    // use greedy
    boolean ok = true;
    int swap = 0;
    if (a>b) {swap = 1;
      int t = a;
      a = b;
      b = t;
    }
    Arrays.sort(locs,new Comparator<int[]>() {
      public int compare(int[] a, int[] b) {
        return (new Integer(a[0])).compareTo(b[0]);
      }
    });
    int[] inB = new int[n];
    for (int[] i: locs) {
      if (in.containsKey(b-i[0])) {
        inB[i[1]] = 1-swap;
        in.remove(b-i[0]);
      } else if (in.containsKey(a-i[0])) {
        inB[i[1]] = swap;
        in.remove(a-i[0]);
      } else ok = false;
    }

    // write to out
    StringBuffer p = new StringBuffer();
    for (int i=0;i<n-1;i++) {
      p.append(inB[i]);
      p.append(" ");
    }
    p.append(inB[n-1]);
    if (ok) {
      out.println("YES");
      out.println(p.toString());
    } else {
      out.println("NO");
    }

    // cleanup
    out.close();
    System.exit(0);
  }
}


import java.io.IOException;
import java.util.Arrays;
import java.util.TreeMap;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author George Marcus
 */
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);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
    ArrayList<Integer>[] G;
    int[] st, dr;
    boolean[] v;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int N = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        int[] A = new int[N];
        TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>();
        for (int i = 0; i < N; i++) {
            A[i] = in.nextInt();
            map.put(A[i], i);
        }
        G = new ArrayList[N];
        for (int i = 0; i < N; i++) {
            G[i] = new ArrayList<Integer>();
        }

        for (int i = 0; i < N; i++) {
            int val = a - A[i];
            if (map.containsKey(val)) {
                int p = map.get(val);
//                if (p != i) {
                    G[i].add(p);
                    G[p].add(i);
//                }
            }
            val = b - A[i];
            if (map.containsKey(val)) {
                int p = map.get(val);
//                if (p != i) {
                    G[i].add(p);
                    G[p].add(i);
//                }
            }
        }

        st = new int[N];
        dr = new int[N];
        Arrays.fill(st, -1);
        Arrays.fill(dr, -1);
        v = new boolean[N];

        boolean ok = true;
        int match = 0;
        while (ok) {
            ok = false;
            Arrays.fill(v, false);
            for (int i = 0; i < N; i++) {
                if (dr[i] == -1) {
                    if (pairup(i)) {
                        ok = true;
                        match++;
                    }
                }
            }
        }

        if (match == N) {
            out.println("YES");
            for (int i = 0; i < N; i++) {
                if (i > 0) {
                    out.print(" ");
                }
                int other = dr[i];
                if (A[i] == b - A[other]) {
                    out.print(1);
                }
                else {
                    out.print(0);
                }
            }
        }
        else {
            out.println("NO");
        }
    }

    private boolean pairup(int node) {
        if (v[node]) {
            return false;
        }
        v[node] = true;
        for (int x : G[node]) {
            if (st[x] == -1) {
                st[x] = node;
                dr[node] = x;
                return true;
            }
        }
        for (int x : G[node]) {
            if (pairup(st[x])) {
                st[x] = node;
                dr[node] = x;
                return true;
            }
        }
        return false;
    }
}

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 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 nextInt() {
        return Integer.parseInt(nextString());
    }

    public String nextString() {
        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;
    }

}


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

public class D909 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[] line = br.readLine().toCharArray();
        int n = line.length;

        int l = 0;
        ArrayList<Node> groups = new ArrayList<>();
        Node node = new Node(line[0], 1);
        groups.add(node);
        for (int i = 1; i < n; i++) {
            if (line[i] == groups.get(l).letter) {
                groups.get(l).count++;
            } else {
                node = new Node(line[i], 1);
                groups.add(node);
                l++;
            }
        }

        int moves = 0;
        ArrayList<Node> temp = new ArrayList<>();
        while (groups.size() > 1) {
            moves++;

            l = groups.size();
            groups.get(0).count--;
            groups.get(l - 1).count--;
            for (int i = 1; i < l - 1; i++) {
                groups.get(i).count -= 2;
            }

            int p;
            for (p = 0; p < l; p++) {
                if (groups.get(p).count > 0) {
                    temp.add(groups.get(p));
                    break;
                }
            }
            int lTemp = temp.size();
            for (p++; p < l; p++) {
                if (groups.get(p).count <= 0) {
                    continue;
                }
                if (groups.get(p).letter == temp.get(lTemp - 1).letter) {
                    temp.get(lTemp - 1).count += groups.get(p).count;
                } else {
                    temp.add(groups.get(p));
                    lTemp++;
                }
            }

            groups.clear();
            groups.addAll(temp);
            temp.clear();
        }

        System.out.println(moves);
    }

    private static class Node {
        char letter;
        int count;

        Node(char letter, int count) {
            this.letter = letter;
            this.count = count;
        }
    }
}


import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class PlayingPiano {

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

		 List<Integer> as = new LinkedList<>();
		 int[] as2 = new int[n];

		 for (int i = 0; i < n; i++) {
			 int a = scanner.nextInt();
			 as.add(a);
			 as2[i] = a;
		 }

		 //System.out.println(solve(as));
		 System.out.println(solve2(as2));

		scanner.close();
	}

	public static String solve(List<Integer> as) {
		List<Integer> fingers = new LinkedList<>();
		 fingers.add(1);
		 fingers.add(2);
		 fingers.add(3);
		 fingers.add(4);
		 fingers.add(5);

		 List<Integer> solution = assign(as, fingers, fingers);
		 if (solution == null) {
			 return "-1";
		 } else {
			 StringBuilder sb = new StringBuilder();
			 for (int b : solution) {
				 sb.append(b);
				 sb.append(" ");
			 }
			 sb.deleteCharAt(sb.length() - 1);
			 return sb.toString();
		 }
	}

	private static List<Integer> assign(List<Integer> as, List<Integer> fingers, List<Integer> allFingers) {
		// if fingers is empty return null
		if (fingers.isEmpty()) {
			return null;
		}

		// if as size is one then return first element in fingers
		if (as.size() == 1) {
			List<Integer> ret = new LinkedList<>();
			ret.add(fingers.get(0));
			return ret;
		}

		// get sublist
		List<Integer> subList = as.subList(1, as.size());

		for (int i = 0; i < fingers.size(); i++) {
			// recursively call with sublist and limited list of fingers
			List<Integer> subFingers = new LinkedList<>();
			final int j = i;
			if (as.get(0) < as.get(1)) {
				 subFingers = allFingers.stream()
					    .filter(p -> p > fingers.get(j)).collect(Collectors.toList());
			} else if (as.get(0) > as.get(1)) {
				subFingers = allFingers.stream()
					    .filter(p -> p < fingers.get(j)).collect(Collectors.toList());
			} else {
				subFingers = allFingers.stream()
					    .filter(p -> p != fingers.get(j)).collect(Collectors.toList());
			}

			List<Integer> ret = assign(subList, subFingers, allFingers);
			if (ret != null) {
				List<Integer> solution = new LinkedList<>();
				solution.add(fingers.get(i));
				solution.addAll(ret);
				return solution;
			}

			// if return is null, then return null, else return an array
		}
		return null;

	}

	public static String solve2(int[] as) {
		int[] ret = new int[as.length];

		if (as.length == 1) return "1";

		if (as[0] < as[1]) ret[0] = 1;
		else if (as[0] == as[1])	ret[0] = 3;
		else ret[0] = 5;

		for (int i = 1; i < as.length - 1; i++) {
			if (as[i-1] < as[i] && ret[i-1] == 5) return "-1";
			if (as[i-1] > as[i] && ret[i-1] == 1) return "-1";

			if (as[i-1] < as[i] && as[i] < as[i+1]) {
				ret[i] = ret[i-1] + 1;
			} else if (as[i-1] == as[i] && as[i] < as[i+1]) {
				ret[i] = ret[i-1] == 1 ? 2 : 1;
			} else if (as[i-1] > as[i] && as[i] < as[i+1]) {
				ret[i] = 1;
			} else if (as[i-1] < as[i] && as[i] == as[i+1]) {
				ret[i] = ret[i-1] + 1;
			} else if (as[i-1] == as[i] && as[i] == as[i+1]) {
				ret[i] = ret[i-1] == 4 ? 2 : 4;
			} else if (as[i-1] > as[i] && as[i] == as[i+1]) {
				ret[i] = ret[i-1] == 2 ? 1 : 2;
			} else if (as[i-1] < as[i] && as[i] > as[i+1]) {
				ret[i] = 5;
			} else if (as[i-1] == as[i] && as[i] > as[i+1]) {
				ret[i] = ret[i-1] == 5 ? 4 : 5;
			} else if (as[i-1] > as[i] && as[i] > as[i+1]) {
				ret[i] = ret[i-1] - 1;
			}
		}

		if (as.length > 1) {
			if (as[as.length - 1] > as[as.length - 2]) {
				if (ret[as.length - 2] == 5)
					return "-1";
				ret[as.length - 1] = 5;
			} else if (as[as.length - 1] == as[as.length - 2]) {
				ret[as.length - 1] = ret[as.length - 2] == 5 ? 4 : 5;
			} else {
				if (ret[as.length - 2] == 1)
					return "-1";
				ret[as.length - 1] = 1;
			}
		}
		StringBuilder sb = new StringBuilder();
		 for (int b : ret) {
			 sb.append(b);
			 sb.append(" ");
		 }
		 sb.deleteCharAt(sb.length() - 1);
		 return sb.toString();
	}

}


import java.util.*;

public class Main{
    private static final int MAX_SIZE = 100005;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(((m + 1) / 60 < a) || ((m + 1) / 60 == a && (m + 1) % 60 <= b)) {
            out(0, 0);
            System.exit(0);
        }
        for(int i = 2; i <= n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();

            int bb = b + 2 * m + 2;
            int aa = a + bb / 60;
            bb %= 60;

            if((aa < x) || (aa == x && bb <= y)) {
                b = b + m + 1;
                a = a + b / 60;
                b %= 60;
                out(a, b);
                System.exit(0);
            }
            a = x;
            b = y;
        }
        b = b + m + 1;
        a = a + b / 60;
        b = b % 60;
        out(a, b);
    }

    private static void out(int a, int b) {
        cout(a);
        cout(" ");
        cout(b);
    }

    private static void cout(Object a) {
        System.out.print(a);
    }
}


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

public class AnnoyingPresent {

	//UPSOLVED
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
        long n = Long.parseLong(st.nextToken()) , m = Long.parseLong(st.nextToken());

        long sum = 0;

        for(int i=0;i<m;i++){
        	StringTokenizer st1 = new StringTokenizer(br.readLine());
            sum+= n* Long.parseLong(st1.nextToken());
            Long a= Long.parseLong(st1.nextToken());
            if(a < 0){
                if(n % 2 == 0)
                    sum += n*n / 4*a;
                else{
                    sum += (n/2) * (n/2+1) * a;
                }
            }
            else
                sum += (a*(n) * (n-1) / 2);

        }
        System.out.println((double)sum/n);
	}

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Don Li
 */
public class SequenceTransformation {
    void solve() {
        int p = 1, n = in.nextInt();
        while (n > 0) {
            if (n == 1) {
                out.print(p + " ");
                break;
            }
            if (n == 2) {
                out.print(p + " ");
                out.print(2 * p + " ");
                break;
            }
            if (n == 3) {
                out.print(p + " ");
                out.print(p + " ");
                out.print(3 * p + " ");
                break;
            }
            for (int i = 0; i < (n + 1) / 2; i++) {
                out.print(p + " ");
            }
            p *= 2;
            n /= 2;
        }
    }

    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new SequenceTransformation().solve();
        out.close();
    }

    static FastScanner in;
    static PrintWriter out;

    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;

        public FastScanner(BufferedReader in) {
            this.in = in;
        }

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

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

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

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


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

public class Main {

    private static void solve(InputReader in, OutputWriter out) {
        int n = in.nextInt();

        List<List<Integer>> g = new ArrayList<>(n + 1);
        for (int i = 0; i < n + 1; i++) {
            g.add(new LinkedList<>());
        }

        int degree1 = 0, degree2 = 0, root = 0;
        for (int i = 0; i < n - 1; i++) {
            int a = in.nextInt();
            int b = in.nextInt();

            g.get(a).add(b);
            g.get(b).add(a);

            if (g.get(a).size() > degree1) {

                if (a == root) {
                    degree1 = g.get(a).size();
                } else {
                    degree2 = degree1;
                    degree1 = g.get(a).size();
                    root = a;
                }

            } else if (g.get(a).size() > degree2) {
                degree2 = g.get(a).size();
            }

            if (g.get(b).size() > degree1) {

                if (b == root) {
                    degree1 = g.get(b).size();
                } else {
                    degree2 = degree1;
                    degree1 = g.get(b).size();
                    root = b;
                }

            } else if (g.get(b).size() > degree2) {
                degree2 = g.get(b).size();
            }
        }

        if (degree2 > 2) {
            out.print("No");
        } else {
            out.println("Yes");

            List<Integer> leaves = new LinkedList<>();
            for (int i = 1; i <= n; i++) {
                if (i != root) {
                    if (g.get(i).size() == 1) {
                        leaves.add(i);
                    }
                }
            }

            out.println(leaves.size());
            for (int i : leaves) {
                out.println(root + " " + i);
            }
        }
    }

    private static void shuffleArray(int[] array) {
        int index;
        Random random = new Random();
        for (int i = array.length - 1; i > 0; i--) {
            index = random.nextInt(i + 1);
            if (index != i) {
                array[index] ^= array[i];
                array[i] ^= array[index];
                array[index] ^= array[i];
            }
        }
    }

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        OutputWriter out = new OutputWriter(System.out);
        solve(in, out);
        in.close();
        out.close();
    }

    private static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        InputReader(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }

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

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String line = nextLine();
                if (line == null) return null;
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        byte nextByte() {
            return Byte.parseByte(next());
        }

        short nextShort() {
            return Short.parseShort(next());
        }

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

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

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

        void close() {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static class OutputWriter {
        BufferedWriter bw;

        OutputWriter(OutputStream os) {
            bw = new BufferedWriter(new OutputStreamWriter(os));
        }

        void print(int i) {
            print(Integer.toString(i));
        }

        void println(int i) {
            println(Integer.toString(i));
        }

        void print(long l) {
            print(Long.toString(l));
        }

        void println(long l) {
            println(Long.toString(l));
        }

        void print(double d) {
            print(Double.toString(d));
        }

        void println(double d) {
            println(Double.toString(d));
        }

        void print(boolean b) {
            print(Boolean.toString(b));
        }

        void println(boolean b) {
            println(Boolean.toString(b));
        }

        void print(char c) {
            try {
                bw.write(c);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        void println(char c) {
            println(Character.toString(c));
        }

        void print(String s) {
            try {
                bw.write(s);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        void println(String s) {
            print(s);
            print('\n');
        }

        void close() {
            try {
                bw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}


import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class A1 {

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

        long size = scan.nextLong();
        int numberOfSpecial = scan.nextInt();
        long pageSize = scan.nextLong();

        long[] specialItemsArray = new long[numberOfSpecial];
        for (int i = 0; i < numberOfSpecial; i++) {
            specialItemsArray[i] = scan.nextLong();
        }

        int totalRemoved = 0;
        int step = 0;

        long currentPageIndex = BigDecimal.valueOf(specialItemsArray[0]).divide(BigDecimal.valueOf(pageSize),2, RoundingMode.UP).setScale(0, RoundingMode.CEILING).longValue();
        int specialItemArrayIndex = 1;

        while (specialItemArrayIndex < numberOfSpecial) {
            long pageIndex = BigDecimal.valueOf(specialItemsArray[specialItemArrayIndex] - totalRemoved).divide(BigDecimal.valueOf(pageSize),2,RoundingMode.UP).setScale(0, RoundingMode.CEILING).longValue();
            if (currentPageIndex != pageIndex) {
                step++;
                totalRemoved = specialItemArrayIndex;
                currentPageIndex =  BigDecimal.valueOf(specialItemsArray[specialItemArrayIndex] - totalRemoved).divide(BigDecimal.valueOf(pageSize),2,RoundingMode.UP).setScale(0, RoundingMode.CEILING).longValue();
            }
            specialItemArrayIndex++;
        }

        System.out.println(step + 1);

    }

}


import java.util.*;
import java.io.*;
public class Solution{

    public static long page(long p,long k){

        return (p-1)/k;

    }

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

        long n = sc.nextLong();
        int m = sc.nextInt();
        long k = sc.nextLong();
        long[] p = new long[m];
        long del = 0;
        long nb = 1;
        int op = 0;
        for(int i=0;i<m;i++) p[i] = sc.nextLong();
        for(int i=1;i<m;i++){
            if(page(p[i]-del,k)!=page(p[i-1]-del,k)){

                del += nb;
                nb = 1;
                op++;

            }else{
                nb++;

            }
        }
        if(nb!=0) op++;

        System.out.println(op);

    }

}


/**
 * BaZ :D
 */
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main
{
    static Reader scan;
    static PrintWriter pw;
    static int n,k,left[],right[],arr[];
    static long MOD = 1000000007,count[],dp[];
    public static void main(String[] args) {
        new Thread(null,null,"BaZ",1<<25)
        {
            public void run()
            {
                try
                {
                    solve();
                }
                catch(Exception e)
                {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }.start();
    }
    static void solve() throws IOException
    {
        scan = new Reader();
        pw = new PrintWriter(System.out,true);
        StringBuilder sb = new StringBuilder();
        n = ni();
        k = ni();
        int stack[] = new int[1000001];
        int top = -1;
        arr = new int[n];
        left = new int[n];
        right = new int[n];
        for(int i=0;i<n;++i) {
            arr[i] = ni();
            while(top>=0 && arr[stack[top]]<=arr[i])
                top--;
            if(top==-1)
                left[i] = 0;
            else left[i] = stack[top]+1;
            stack[++top] = i;
        }
        top = -1;
        for(int i=n-1;i>=0;--i) {
            while(top>=0 && arr[stack[top]]<arr[i])
                top--;
            if(top==-1)
                right[i] = n-1;
            else right[i] = stack[top]-1;
            stack[++top] = i;
        }
        //pa("left", left);
        //pa("right", right);
        dp = new long[n+1];
        for(int i=0;i<=n;++i) {
            if(i<k)
              continue;
            dp[i] = dp[i-k+1] + (i-k+1);
        }
        count = new long[n];
        long ans = 0;
        for(int i=0;i<n;++i) {
            int len = right[i]-left[i]+1;
            int lef = i-left[i];
            int rig = right[i]-i;
            long count = dp[len] - dp[lef] - dp[rig];
            if(count>=MOD)
              count%=MOD;
            ans += count*arr[i];
            if(ans>=MOD)
                ans%=MOD;
        }
        pl(ans);
        pw.flush();
        pw.close();
    }
    static int ni() throws IOException
    {
        return scan.nextInt();
    }
    static long nl() throws IOException
    {
        return scan.nextLong();
    }
    static double nd() throws IOException
    {
        return scan.nextDouble();
    }
    static void pl()
    {
        pw.println();
    }
    static void p(Object o)
    {
        pw.print(o+" ");
    }
    static void pl(Object o)
    {
        pw.println(o);
    }
    static void psb(StringBuilder sb)
    {
        pw.print(sb);
    }
    static void pa(String arrayName, Object arr[])
    {
        pl(arrayName+" : ");
        for(Object o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, int arr[])
    {
        pl(arrayName+" : ");
        for(int o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, long arr[])
    {
        pl(arrayName+" : ");
        for(long o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, double arr[])
    {
        pl(arrayName+" : ");
        for(double o : arr)
            p(o);
        pl();
    }
    static void pa(String arrayName, char arr[])
    {
        pl(arrayName+" : ");
        for(char o : arr)
            p(o);
        pl();
    }
    static void pa(String listName, List list)
    {
        pl(listName+" : ");
        for(Object o : list)
            p(o);
        pl();
    }
    static void pa(String arrayName, Object[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(Object o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, int[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(int o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, long[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(long o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, char[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(char o : arr[i])
                p(o);
            pl();
        }
    }
    static void pa(String arrayName, double[][] arr) {
        pl(arrayName+" : ");
        for(int i=0;i<arr.length;++i) {
            for(double o : arr[i])
                p(o);
            pl();
        }
    }
    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader() {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException {
            byte[] buf = new byte[64];
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n') break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException {
            int ret = 0;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg) return -ret;
            return ret;
        }

        public long nextLong() throws IOException {
            long ret = 0;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg) return -ret;
            return ret;
        }

        public double nextDouble() throws IOException {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ') c = read();
            boolean neg = (c == '-');
            if (neg) c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (c == '.') while ((c = read()) >= '0' && c <= '9') ret += (c - '0') / (div *= 10);
            if (neg) return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1) buffer[0] = -1;
        }

        private byte read() throws IOException {
            if (bufferPointer == bytesRead) fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException {
            if (din == null) return;
            din.close();
        }
    }
}


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

public class _1036_B_DiagonalWalkingV2 {

	public static void main(String[] args) throws IOException {
		int Q = readInt();
		while(Q-- > 0) {
			long n = readLong(), m = readLong(), k = readLong();
			if(Math.max(n, m) > k) println(-1);
			else {
				long ans = k;
				if(n%2 != k%2) ans--;
				if(m%2 != k%2) ans--;
				println(ans);
			}
		}
		exit();
	}

	final private static int BUFFER_SIZE = 1 << 16;
	private static DataInputStream din = new DataInputStream(System.in);
	private static byte[] buffer = new byte[BUFFER_SIZE];
	private static int bufferPointer = 0, bytesRead = 0;
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	public static String readLine() throws IOException {
		byte[] buf = new byte[64]; // line length
		int cnt = 0, c;
		while ((c = Read()) != -1) {
			if (c == '\n')
				break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	public static String read() throws IOException {
		byte[] ret = new byte[1024];
		int idx = 0;
		byte c = Read();
		while (c <= ' ') {
			c = Read();
		}
		do {
			ret[idx++] = c;
			c = Read();
		} while (c != -1 && c != ' ' && c != '\n' && c != '\r');
		return new String(ret, 0, idx);
	}

	public static int readInt() throws IOException {
		int ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (neg)
			return -ret;
		return ret;
	}

	public static long readLong() throws IOException {
		long ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');
		if (neg)
			return -ret;
		return ret;
	}

	public static double readDouble() throws IOException {
		double ret = 0, div = 1;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();

		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (c == '.') {
			while ((c = Read()) >= '0' && c <= '9') {
				ret += (c - '0') / (div *= 10);
			}
		}

		if (neg)
			return -ret;
		return ret;
	}

	private static void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
		if (bytesRead == -1)
			buffer[0] = -1;
	}

	private static byte Read() throws IOException {
		if (bufferPointer == bytesRead)
			fillBuffer();
		return buffer[bufferPointer++];
	}

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		din.close();
		pr.close();
		System.exit(0);
	}
}


//package com.krakn.CF.D1159;

import java.util.Scanner;

public class Main {

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

        int n, k;
        n = sc.nextInt();
        k = sc.nextInt();

        int a = (n - k) / 2;

        StringBuilder s = new StringBuilder();

        int i;
        while (s.length() < n) {
            i = 0;
            while (i < a && s.length() < n) {
                s.append("0");
                i++;
            }
            if (s.length() < n) s.append("1");
        }

        System.out.println(s);
    }
}


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

public class Main {

    private static void solve(InputReader in, OutputWriter out) {
        int n = in.nextInt();

        if (n < 6) {
            out.println(-1);
        } else {
            int m = (n - 2);
            for (int i = 2; i <= m; i++) {
                out.println("1 " + i);
            }
            out.println(m + " " + (m + 1));
            out.println(m + " " + (m + 2));
        }

        for (int i = 2; i <= n; i++) {
            out.println("1 " + i);
        }
    }

    private static void shuffleArray(int[] array) {
        int index;
        Random random = new Random();
        for (int i = array.length - 1; i > 0; i--) {
            index = random.nextInt(i + 1);
            if (index != i) {
                array[index] ^= array[i];
                array[i] ^= array[index];
                array[index] ^= array[i];
            }
        }
    }

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        OutputWriter out = new OutputWriter(System.out);
        solve(in, out);
        in.close();
        out.close();
    }

    private static class InputReader {
        private BufferedReader br;
        private StringTokenizer st;

        InputReader(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }

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

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                String line = nextLine();
                if (line == null) return null;
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

        byte nextByte() {
            return Byte.parseByte(next());
        }

        short nextShort() {
            return Short.parseShort(next());
        }

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

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

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

        void close() {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static class OutputWriter {
        BufferedWriter bw;

        OutputWriter(OutputStream os) {
            bw = new BufferedWriter(new OutputStreamWriter(os));
        }

        void print(int i) {
            print(Integer.toString(i));
        }

        void println(int i) {
            println(Integer.toString(i));
        }

        void print(long l) {
            print(Long.toString(l));
        }

        void println(long l) {
            println(Long.toString(l));
        }

        void print(double d) {
            print(Double.toString(d));
        }

        void println(double d) {
            println(Double.toString(d));
        }

        void print(boolean b) {
            print(Boolean.toString(b));
        }

        void println(boolean b) {
            println(Boolean.toString(b));
        }

        void print(char c) {
            try {
                bw.write(c);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        void println(char c) {
            println(Character.toString(c));
        }

        void print(String s) {
            try {
                bw.write(s);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        void println(String s) {
            print(s);
            print('\n');
        }

        void close() {
            try {
                bw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

959_C. Mahmoud and Ehab and the wrong algorithm


 import java.io.*;
import java.util.*;
import java.lang.*;
import java.awt.*;
import java.awt.geom.*;
import java.math.*;
import java.text.*;
import java.math.BigInteger.*;
import java.util.Arrays;

public class   CF111111
{
  BufferedReader in;
  StringTokenizer as;
  int nums[],nums2[];
  int[] nums1[];
  boolean con = true;

  ArrayList < Integer >  ar = new ArrayList < Integer >();
  ArrayList < Integer >  fi = new ArrayList < Integer >();
  Map<Integer,Integer > map = new HashMap<Integer, Integer>();
  public static void main (String[] args)
  {
    new CF111111  ();
  }

  public int GCD(int a, int b) {
    if (b==0) return a;
    return GCD(b,a%b);
  }

  public int LIS(int arr[])
  {
    int n = arr.length;
    int sun[] = new int [n];
    int cur = 0;
    for(int x = 0;x<n;x++)
    {
      int temp = Arrays.binarySearch(sun,0,cur,arr[x]);
      if(temp < 0)
        temp = -temp -1;
      sun[temp] = arr[x];
      if(temp == cur)
        cur++;
    }
    return cur;

  }

  public CF111111  ()
  {
    try
    {

      in = new BufferedReader (new InputStreamReader (System.in));
      int a = nextInt();
      for(int xx1 = 0;xx1<a;xx1++)
      {
        int b = nextInt();
        nums = new int [b];
        for(int x = 0;x<b;x++)
        {
          nums[x] = nextInt();
        }
         int max = 0;
         int max2 = -1;
         for(int x = 0;x<b;x++)
         {
           if(nums[x] >= max)
           {
             max2 = max;
             max = nums[x];
           }
           else if(nums[x] >= max2)
             max2 = nums[x];
         }
        System.out.println(Math.min(max2, b-1)-1);
      }
    }
    catch(IOException e)
    {

    }
  }

  String next () throws IOException
  {
    while (as == null || !as.hasMoreTokens ())
    {
      as = new StringTokenizer (in.readLine ().trim ());
    }

    return as.nextToken ();
  }

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

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

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

  String nextLine () throws IOException
  {
    return in.readLine ().trim ();
  }
}


import java.util.*;
import java.io.*;
import java.math.*;
public class Solution{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(br.readLine());
        StringTokenizer st;
        for(int z=0;z<t;z++){
            st = new StringTokenizer(br.readLine());
            int n = Integer.parseInt(st.nextToken());
            st = new StringTokenizer(br.readLine());
            int min=1;
            int max=1;
            for(int i=0;i<n;i++){
                int k = Integer.parseInt(st.nextToken());
                if(max<k){
                    min = max;
                    max = k;
                }else if(min<k){
                    min = k;
                }
            }
            int res = Math.min(n-2,min-1);
            System.out.println(res);
        }
    }
}


//package com.krakn.CF.B1159;

import java.util.Scanner;

public class Main {

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

        int n;
        n = sc.nextInt();
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }

        int min = 1000000000, temp;

        for (int i = 0; i < n; i++) {
            temp = arr[i] / Math.max(i, n - 1 - i);
            if (temp < min)
                min = temp;
//            System.out.println(i + " " + temp);
        }

        System.out.println(min);
    }
}

1159_B. Expansion coefficient of the array


import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

public class Main {
    public static void main(String[] args)
    {
        Scanner stdin = new Scanner(System.in);
        /*int n = stdin.nextInt();
        for(int i = 0; i < n; i++)
        {
        	test(stdin);
        }*/
        test(stdin);
        stdin.close();
    }
    public static void test(Scanner stdin)
    {
    	int n = stdin.nextInt();
    	int min = Integer.MAX_VALUE;
    	for(int i = 0; i < n; i++)
    	{
    		int a = stdin.nextInt();
    		if((int)((1.0)*a/(Math.max(i, n - i - 1))) < min)
    		{ min = (int)((1.0)*a/(Math.max(i, n - i - 1))); }
    	}
    	System.out.println(min);
    }
}


// practice with rainboy
import java.io.*;
import java.util.*;

public class CF903F {
	static final int INF = 0x3f3f3f3f;
	static void fill(int[][][][] aa, int a) {
		for (int h0 = 0; h0 <= 4; h0++)
			for (int h1 = 0; h1 <= 4; h1++)
				for (int h2 = 0; h2 <= 4; h2++)
					for (int h3 = 0; h3 <= 4; h3++)
						aa[h0][h1][h2][h3] = a;
	}
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		int a1 = Integer.parseInt(st.nextToken());
		int a2 = Integer.parseInt(st.nextToken());
		int a3 = Integer.parseInt(st.nextToken());
		int a4 = Integer.parseInt(st.nextToken());
		int[] aa = new int[10];
		aa[0] = aa[1] = aa[2] = aa[3] = a1;
		aa[4] = aa[5] = aa[6] = a2;
		aa[7] = aa[8] = a3;
		aa[9] = a4;
		int[][] ww = new int[10][4];
		ww[0][0] = 1;
		ww[1][1] = 1;
		ww[2][2] = 1;
		ww[3][3] = 1;
		ww[4][0] = ww[4][1] = 2;
		ww[5][1] = ww[5][2] = 2;
		ww[6][2] = ww[6][3] = 2;
		ww[7][0] = ww[7][1] = ww[7][2] = 3;
		ww[8][1] = ww[8][2] = ww[8][3] = 3;
		ww[9][0] = ww[9][1] = ww[9][2] = ww[9][3] = 4;
		char[][] cc = new char[4][n + 8];
		for (int k = 0; k < 4; k++) {
			char[] c_ = cc[k];
			br.readLine().getChars(0, n, c_, 4);
			c_[0] = c_[1] = c_[2] = c_[3]
				= c_[n + 4] = c_[n + 5] = c_[n + 6] = c_[n + 7] = '.';
		}
		int[][][][] dp = new int[5][5][5][5];
		int[][][][] dq = new int[5][5][5][5];
		fill(dp, INF);
		dp[4][4][4][4] = 0;
		int[] hh = new int[4];
		for (int i = 0; i < n + 4; i++) {
			for (int h0 = 0; h0 <= 4; h0++)
				for (int h1 = 0; h1 <= 4; h1++)
					for (int h2 = 0; h2 <= 4; h2++)
						for (int h3 = 0; h3 <= 4; h3++)
							for (int s = 0; s < 10; s++) {
								hh[0] = h0;
								hh[1] = h1;
								hh[2] = h2;
								hh[3] = h3;
								for (int k = 0; k < 4; k++) {
									int h = ww[s][k];
									if (hh[k] < h) {
										while (h < 4 && cc[k][i + h] == '.')
											h++;
										hh[k] = h;
									}
								}
								int x = dp[h0][h1][h2][h3] + aa[s];
								if (dp[hh[0]][hh[1]][hh[2]][hh[3]] > x)
									dp[hh[0]][hh[1]][hh[2]][hh[3]] = x;
							}
			fill(dq, INF);
			for (int h0 = 1; h0 <= 4; h0++) {
				hh[0] = h0 < 4 || cc[0][i + 4] == '*' ? h0 - 1 : 4;
				for (int h1 = 1; h1 <= 4; h1++) {
					hh[1] = h1 < 4 || cc[1][i + 4] == '*' ? h1 - 1 : 4;
					for (int h2 = 1; h2 <= 4; h2++) {
						hh[2] = h2 < 4 || cc[2][i + 4] == '*' ? h2 - 1 : 4;
						for (int h3 = 1; h3 <= 4; h3++) {
							hh[3] = h3 < 4 || cc[3][i + 4] == '*' ? h3 - 1 : 4;
							int x = dp[h0][h1][h2][h3];
							if (dq[hh[0]][hh[1]][hh[2]][hh[3]] > x)
								dq[hh[0]][hh[1]][hh[2]][hh[3]] = x;
						}
					}
				}
			}
			int[][][][] tmp = dp; dp = dq; dq = tmp;
		}
		System.out.println(dp[4][4][4][4]);
	}
}


import java.io.*;
import java.util.*;
public class GFG {
	public static void main (String[] args) {
	    Scanner sc = new Scanner (System.in);
	    int n = sc.nextInt();
	    int a = sc.nextInt();
	    int b = sc.nextInt();
	    int c = sc.nextInt();
	    int ans = 0;
	    int t= sc.nextInt();
	    int arr[] = new int[n];
	    for(int i=0;i<n;i++){
	        int nn = sc.nextInt();
	        ans+=a;
	        if(b<c){
	            ans += (t-nn) * (c - b);
	        }
	    }
	    System.out.println(ans);
	}
}


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

public class Cf1017A {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int result = 1;
        int thomasSum = 0;
        StringTokenizer stk;
        stk = new StringTokenizer(br.readLine());
        int first = Integer.parseInt(stk.nextToken());
        int second = Integer.parseInt(stk.nextToken());
        int third = Integer.parseInt(stk.nextToken());
        int fourth = Integer.parseInt(stk.nextToken());
        thomasSum = first + second + third + fourth;
        int tmp;
        for (int i = 1; i < n; i++) {
            stk = new StringTokenizer(br.readLine());
            first = Integer.parseInt(stk.nextToken());
            second = Integer.parseInt(stk.nextToken());
            third = Integer.parseInt(stk.nextToken());
            fourth = Integer.parseInt(stk.nextToken());
            tmp = first + second + third + fourth;
            if (tmp > thomasSum)
                result++;
        }
        System.out.println(result);
    }
}


import java.util.*;

public class helloWorld
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int[] ar = new int[200];

		String str = in.next();
		for(int i = 0; i < str.length(); i++)
			ar[ str.charAt(i) ]++;

		int ans = 100000;

		for(int i = 'A'; i < 'A' + m; i++)
			ans = Math.min(ans, ar[i]);
		ans *= m;

		System.out.println(ans);

		in.close();
	}
}


import java.util.Scanner;

public class TreasureHunt {

	public static String Solve() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		String kuro = sc.nextLine(), shiro = sc.nextLine(), katie = sc.nextLine();
		sc.close();
		String[] output = {"Kuro", "Shiro", "Katie", "Draw"};
		if(n >= kuro.length())
			return output[3];
		int[] maxArr = new int[3];
		int[][] freq = new int[3][58];
		for(int i = 0; i < kuro.length(); i++) {
			maxArr[0] = ++freq[0][kuro.charAt(i) - 65] > maxArr[0]? freq[0][kuro.charAt(i) - 65] : maxArr[0];
			maxArr[1] = ++freq[1][shiro.charAt(i) - 65] > maxArr[1]? freq[1][shiro.charAt(i) - 65] : maxArr[1];
			maxArr[2] = ++freq[2][katie.charAt(i) - 65] > maxArr[2]? freq[2][katie.charAt(i) - 65] : maxArr[2];
		}
		int winner = 0, max = 0;
		for(int i = 0; i < 3; i++) {
			if(kuro.length() - maxArr[i] >= n)
				maxArr[i] += n;
			else
				maxArr[i] = n == 1? kuro.length() - 1: kuro.length();
			if(max < maxArr[i]) {
				winner = i;
				max = maxArr[i];
			} else if(max == maxArr[i])
				winner = 3;
		}

		return output[winner];
	}
	public static void main(String[] args) {
		System.out.println(Solve());
	}
}