import java.util.Scanner;

public class ProblemC {

    public static void main(String[] args) {
        ProblemC problem = new ProblemC();
        problem.solve();
    }

    private void solve() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int ret = n;
        int toth = 0;
        int tott = 0;
        for (int j = 0; j < n; j++) {
            if (s.charAt(j) == 'H') {
                toth++;
            } else {
                tott++;
            }
        }
        for (int j = 0; j < n; j++) {
            int cnth = 0;
            for (int k = 0; k < toth; k++) {
                int pos = (j + k) % n;
                if (s.charAt(pos) == 'H') {
                    cnth++;
                }
            }
            int makeh = toth - cnth;
            ret = Math.min(ret, makeh);
        }
        System.out.println(ret);
    }

}


import java.util.*;
import java.math.*;
import static java.lang.Character.isDigit;
import static java.lang.Character.isLowerCase;
import static java.lang.Character.isUpperCase;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Character.isDigit;

public class Main{
    public static void main(String[] args) {
        new Main().run();
    }
    Scanner sc=new Scanner(System.in);
    void run() {
        int n=sc.nextInt();
        char[] cs=sc.next().toCharArray();
        int h=0;
        for(int i=0;i<n;i++)if(cs[i]=='H')h++;
        int res=n;
        for(int i=0;i<n;i++) {
            int val=0;
            for(int j=0;j<h;j++)if(cs[(i+j)%n]=='T')val++;
            res=min(res,val);
        }
        System.out.println(res);
    }
}


import com.sun.org.apache.xpath.internal.axes.SubContextList;
import java.util.Scanner;

/**
 *
 * @author Madi
 */
public class Round42CC {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String s = sc.nextLine();

        int k = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == 'H') {
                k++;
            }
        }

        s = s + s.substring(0, k);
        String ss = "";

        int max = 0;
        for (int i = 0; i < s.length() - k; i++) {
            ss = s.substring(i, i + k);
            int count = 0;
            for (int j = 0; j < ss.length(); j++) {
                if (ss.charAt(j) == 'H') {
                    count++;
                }
            }
            if (count > max) {
                max = count;
            }
        }

        System.out.println(k - max);
    }
}


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

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

		// 1 = H, 0 = T

		int n = in.nextInt();
		String line = in.next();
		int h = 0;
		for (int i = 0; i < line.length(); i++) {
			if(line.charAt(i)=='H') h++;
		}
		line = line + line;

		int min = Integer.MAX_VALUE;
		for (int i = 0; i < n; i++) {
			int ans = 0;
			for (int j = i; j < i+h; j++) {
				if(line.charAt(j)!='H') ans++;
			}
			if(min>ans) min = ans;
		}

		out.print(min);

		in.close();
		out.close();
	}

}


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

public class HamstersAndTigers
{
	Scanner in;
	PrintWriter out;

	HamstersAndTigers()
	{
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
	}

	HamstersAndTigers(String i, String o) throws FileNotFoundException
	{
		in = new Scanner(new File(i));
		out = new PrintWriter(new File(o));
	}

	public void finalize()
	{
		out.flush();
		in.close();
		out.close();
	}

	void solve()
	{
		int i = 0,
			h = 0,
			n = in.nextInt();

		String buf = "";
		char[] ht = in.next().toCharArray();

		for(i = 0; i < n; ++i)
			if(ht[i] == 'H')
				++h;

		for(i = 0; i < h; ++i)
			buf += 'H';

		for(i = 0; i < n - h; ++i)
			buf += 'T';

		int diff = (1 << 28);
		for(i = 0; i < n; ++i)
		{
			int tmp = 0;

			for(int j = 0; j < n; ++j)
				if(buf.charAt(j) != ht[(i + j) % n])
					++tmp;

			diff = Math.min(tmp, diff);
		}

		out.println(diff / 2);
	}

	public static void main(String[] args) throws FileNotFoundException
	{
		HamstersAndTigers t = new HamstersAndTigers();
		t.solve();
		t.finalize();
	}
}


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

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));

		int size= Integer.parseInt(r.readLine());
		String line = r.readLine();

		int counter =0;
		for (int i = 0; i < line.length(); i++) {
			if(line.charAt(i)=='H')counter++;
		}

		int minimum = Integer.MAX_VALUE;
		for (int i = 0; i < line.length(); i++) {
			if(line.charAt(i)=='H'){
				int current = 0;
				for (int j = i; j < i+counter; j++) {
					if(line.charAt(j%line.length())=='T')current++;
				}
				minimum = Math.min(current, minimum);
			}
		}

		System.out.println(minimum);

	}
}


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

public class Main implements Runnable {
	BufferedReader in;
	PrintStream out;
	StringTokenizer st = new StringTokenizer("");
	static boolean local = false;

	public static void main(String [] args) throws Exception {
		if (args.length > 0) local = true;
		new Thread(new Main()).start();
	}

	void printExit(String s) {
		out.println(s);
		System.exit(0);
	}

	public void run() {
		try {
			Locale.setDefault(Locale.US);
			in = local ? new BufferedReader(new FileReader("input.txt")) : new BufferedReader(new InputStreamReader(System.in));
			out = local ? new PrintStream(new File("output.txt")) : new PrintStream(System.out);
			int n = nextInt();
			char [] c = in.readLine().toCharArray();
			int t = 0;
			for (int i = 0; i < n; i++)
				if (c[i] == 'T') t++;

			int ans = n;
			for (int i = 0; i < n; i++) {
				int cnt = 0;
				for (int j = 0; j < t; j++)
					if (c[(i + j) % n] == 'H')
						cnt++;
				ans = min(ans, cnt);
			}

			out.println(ans);

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

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

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

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

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

 	BigInteger nextBigInteger() {
 	 	return new BigInteger(nextToken());
 	}

 	String nextToken() {
 	 	seekForToken();
 	 	return st.nextToken();
 	}

}


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

public class Main {

    void run() throws IOException {
        int n = in.nextInt();
        char[] c = in.next().toCharArray();
        int[][] t = new int[n][n];
        int[][] h = new int[n][n];
        int allt = 0, allh = 0;
        for (int i = 0; i < n; i++) {
            if (c[i] == 'T') {
                allt++;
            } else {
                allh++;
            }
        }
        for (int i = 0; i < n; i++) {
            if (c[i] == 'T') {
                t[i][i] = 1;
                h[i][i] = 0;
            } else {
                t[i][i] = 0;
                h[i][i] = 1;
            }
            for (int j = i + 1; j < n; j++) {
                if (c[j] == 'T') {
                    t[i][j] = t[i][j - 1] + 1;
                    h[i][j] = h[i][j - 1];
                } else {
                    h[i][j] = h[i][j - 1] + 1;
                    t[i][j] = t[i][j - 1];
                }
            }
        }
        for (int i = 1; i < n; i++) {
            t[i][i - 1] = allt;
            h[i][i - 1] = allh;
            for (int j = 0; j < i - 1; j++) {
                t[i][j] = allt - t[j + 1][i - 1];
                h[i][j] = allh - h[j + 1][i - 1];
            }
        }
        int r = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (h[i][j] == t[(j + 1) % n][(i - 1 + n) % n]) {
                    r = min(r, h[i][j]);
                }
                if (t[i][j] == h[(j + 1) % n][(i - 1 + n) % n]) {
                    r = min(r, t[i][j]);
                }
            }
        }
        out.println(r);
       /* for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
               out.print(t[i][j] + " ");
            }
            out.println();
        }
        out.println();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                out.print(h[i][j] + " ");
            }
            out.println();
        }*/
    }

    class pair implements Comparable <pair> {
        int x, y;
        pair(int x, int y) {
            this.x = x;
            this.y = y;
        }
        public int compareTo (pair p) {
            if (x != p.x) {
                return x - p.x;
            } else {
                return y - p.y;
            }
        }
    }

    static PrintWriter out;
    static Scanner in;

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        //final String FILENAME = "jury"; in = new Scanner (new File (FILENAME + ".in")); out = new PrintWriter (new File(FILENAME + ".out"));
        in = new Scanner (System.in); out = new PrintWriter (System.out);
        new Main().run();
        /*out = new PrintWriter (System.out);
        final int NUMBER_OF_TESTS = 35;
        for (int i = 1; i <= NUMBER_OF_TESTS; i++) {
            Scanner test = new Scanner (new File ("tests/" + i + ".in"));
            Scanner right = new Scanner (new File ("tests/" + i + ".out"));
            String get_right = right.nextLine();
            String get_test = new Main().run(test);
            if (get_right.equals(get_test)) {
                out.println("Test #" + i + ": " + "OK!");
            } else {
                out.println("Test #" + i + ": " + "ERROR!");
                out.println("Expected: " + get_right);
                out.println("Received: " + get_test);
                break;
            }
        }*/
        out.close();
    }
}


import java.util.Scanner;

/**
 *
 * @author igor_kz
 */
public class C46 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int number = in.nextInt();
        String s = in.next();
        int cH = 0;
        int n = s.length();
        for (int i = 0 ; i < n ; i++)
            if (s.charAt(i) == 'H') cH++;
        String ss = "";
        for (int i = 0 ; i < cH ; i++)
            ss += "H";
        for (int i = 0 ; i < n - cH ; i++)
            ss += "T";
        int res = Integer.MAX_VALUE;
        for (int i = 0 ; i < n ; i++) {
            int cur = countDifference(ss , s);
            res = Math.min(res , cur);
            ss = ss.substring(1) + ss.charAt(0);
        }
        System.out.println(res);
    }

    public static int countDifference(String ss, String s) {
        int cnt = 0;
        for (int i = 0 ; i < ss.length() ; i++)
            if (ss.charAt(i) != s.charAt(i)) cnt++;
        return cnt / 2;
    }
}


//package round43;

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

public class C {

	static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;
	static PrintWriter out = new PrintWriter(System.out);

	static String nextToken() throws IOException{
		while (st==null || !st.hasMoreTokens()){
			String s = bf.readLine();
			if (s == null)
				return null;
			st = new StringTokenizer(s);
		}

		return st.nextToken();
	}

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

	static String nextStr() throws IOException{
		return nextToken();
	}

	static int f(byte s[], int n){
		int l = 0,
			r = n-1;
		int res = 0;

		do{
			while (l<n && s[l]=='H')
				l++;
			while (r>=0 && s[r]=='T')
				r--;

			if (l < r){
				res++;
			}
			l++;
			r--;
		}
		while (l < r);

		return res;
	}

	public static void main(String[] args) throws IOException{
		int n = nextInt();
		byte s[] = nextStr().getBytes();

		int res = f(s, n);
		for (int i=1; i<n; i++){
			byte c = s[0];
			for (int j=0; j<n-1; j++)
				s[j] = s[j+1];
			s[n-1] = c;
			res = Math.min(res, f(s, n));
		}

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

}


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

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

        int n = Integer.parseInt(br.readLine());

        int[] a = new int[n];
        int[] b = new int[n];

        StringTokenizer st = new StringTokenizer(br.readLine());

        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(st.nextToken());
        }
        st = new StringTokenizer(br.readLine());
        for (int i = 0; i < n; i++) {
            b[i] = Integer.parseInt(st.nextToken());
        }

        solve(n, a, b, out);
        out.flush();
        out.close();
    }

    private static void solve(int n, int[] a, int[] b, PrintWriter out) {
        boolean[] book = new boolean[n+1];
        boolean f;
        int j1 = 0, j2 = 0;
        for (int i = 0; i < n; i++) {
            f = false;
            int num = b[i];
            if(!book[num]) {
                f = true;
                j1 = j2;
                for (;j2 < n; j2++) {
                    book[a[j2]] = true;
                    if (a[j2] == num) {
                        j2++;
                        break;
                    }
                }
            }
            out.print(f ? j2-j1 + " ": 0 + " ");
        }
    }
}


import java.util.*;
public class Test { public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n= sc.nextInt();
int x= (int)Math.sqrt(n) ;
int a[] = new int[n+5];
for(int i=1,o=n,j;i<=n;i+=x)
for(j=(int)Math.min(i+x-1,n);j>=i;a[j--]=o--);
for(int i=1;i<=n;i++)System.out.print(a[i]+" ");
System.out.println();

}
}


import java.util.Scanner;

public class Solution {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();

		StringBuilder ans = new StringBuilder();
		int count = 0;
		int open = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) == '(') {
				ans.append("(");
				count++;
				open++;
			} else {
				ans.append(")");
				open--;
			}
			if (count == k / 2) {
				break;
			}
		}

		while (open > 0) {
			ans.append(")");
			open--;
		}
		System.out.println(ans.toString());
	}
}


import java.util.*;
public class Main {

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n=scan.nextInt();
        int m=scan.nextInt();
        int[] game=new int[n];
        int[] bill=new int[m];
        for (int i = 0; i <n ; i++) {
            game[i]=scan.nextInt();
        }
        for (int i = 0; i <m ; i++) {
            bill[i]=scan.nextInt();
        }
        int i=0;
        int j=0;
        int ans=0;
        while (i<m){
            boolean f=true;
            for (int k = j; k <n ; k++) {
                if (bill[i]>=game[k]){
                    ans++;
                    i++;
                    j=k+1;
                    f=false;
                    break;
                }
            }
            if (f){
                break;
            }
        }
        System.out.println(ans);
    }
}


import java.util.*;
import java.io.*;
public class A
{
      public static void main(String ar[]) throws Exception
      {
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String s1[]=br.readLine().split(" ");
            String s2[]=br.readLine().split(" ");
            int n=Integer.parseInt(s1[0]);
            int m=Integer.parseInt(s1[1]);
            int a[]=new int[n];
            int b[]=new int[n];
            int c[]=new int[n];
            int d[]=new int[n];
            HashSet<Integer> hs=new HashSet<Integer>();
            hs.add(0);
            hs.add(m);
            int max=0;
            for(int i=0;i<n;i++)
            {
                  a[i]=Integer.parseInt(s2[i]);
                  if(i%2==0)
                   b[i]=1;
                  hs.add(a[i]);
            }

            c[0]=a[0];
            for(int i=1;i<n;i++)
            {
                  if(b[i]==0)
                   c[i]=c[i-1];
                  else
                   c[i]=c[i-1]+a[i]-a[i-1];
            }

            if(b[n-1]==0)
             d[n-1]=m-a[n-1];
            for(int i=n-2;i>=0;i--)
            {
                  if(b[i]==1)
                   d[i]=d[i+1];
                  else
                   d[i]=d[i+1]+a[i+1]-a[i];
            }

            max=c[n-1];
            if(b[n-1]==0)
             max+=m-a[n-1];
            //System.out.println(max);
            for(int i=n-1;i>=0;i--)
            {
                  int u=a[i]-1;
                  int v=a[i]+1;
                  if(!hs.contains(u))
                  {
                        if(b[i]==0)
                        {
                             int r=1+m-a[i]-d[i]+c[i-1];
                             max=Math.max(max,r);
                        }
                        else
                        {
                              int l=0;
                              if(i>0)
                               l=a[i-1];
                              int r=c[i]-1+m-a[i]-d[i];
                              max=Math.max(max,r);
                        }
                  }

                  if(!hs.contains(v))
                  {
                        if(b[i]==0)
                        {
                           if(i==n-1)
                           {
                              int r=c[i]+1;
                              max=Math.max(max,r);
                           }
                           else
                           {
                               int r=c[i]+1+m-a[i+1]-d[i+1];
                               max=Math.max(max,r);
                           }
                        }
                        else
                        {
                                if(i==n-1)
                                {
                                   int r=c[i]+m-a[i]-1;
                                   max=Math.max(max,r);
                                }
                                else
                                {
                                    int r=c[i]+m-a[i+1]-d[i+1]+a[i+1]-1-a[i];
                                    max=Math.max(max,r);
                                }
                        }
                  }
            }

            System.out.println(max);
      }
}


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

public class LightItUp {

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

		int n = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());
		int previous = 0;
		int array[] = new int[n+1];
		int answer = 0;

		StringTokenizer st1 = new StringTokenizer(br.readLine());
		for(int i = 0; i < n; i++){
			array[i] = Integer.parseInt(st1.nextToken());
			if(i % 2 == 0){
				answer += (array[i] - previous);
			}
			previous = array[i];
		}

		if(n % 2 == 0){
			answer += (m - previous);
		}
		previous = m;
		int max = Integer.MAX_VALUE;

		while(n-- != 0){
			int temp = array[n];
			if(n%2 == 0){
				array[n] = array[n+1] - (previous - array[n]);
			}
			else{
				array[n] = array[n+1] + (previous - array[n]);
			}
			previous = temp;
			max = Math.min(max, array[n]);
		}
		if(max>=-1){
			System.out.println(answer);
		}
		else{
			System.out.println(answer - (max+1));
		}

	}

}


import java.util.*;
public class A
{
    public static int palin(String str)
    {
        int flag=0;
        int l=str.length();
        for(int i=0;i<l/2;i++)
        {
            if(str.charAt(i)!=str.charAt(l-i-1))
            {
                flag=1;
                break;
            }
        }
        if(flag==1)
        return 0;
        else
        return 1;
    }
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        String str=sc.next();
        HashSet<Character> hs=new HashSet<>();
        for(int i=0;i<str.length();i++)
        {
            hs.add(str.charAt(i));
        }
        if(hs.size()==1)
        System.out.println(0);
        else if(palin(str)==0)
        System.out.println(str.length());
        else
        System.out.println(str.length()-1);
    }
}


import java.util.*;

public class Main {
    static int n=5;
    static int[] arr=new int[5];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int arr[]=new int[n];
        for (int i=0;i<n;i++)
        {
            arr[i]=sc.nextInt();
        }
        for (int i=0;i<n;i++)
        {
            if (arr[i]>=0)
            {
                arr[i]=-arr[i]-1;
            }
        }
        if (n%2!=0)
        {
            int min=0;
            for (int i=1;i<n;i++)
            {
                if (arr[i]<arr[min])
                    min=i;
            }
            arr[min]=-arr[min]-1;
        }
        for (int x:arr)
        {
            System.out.print(x + " ");
        }

    }
}


import java.util.Scanner;

public class NickAndArray {
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		 int array[]=new int[n];
		 int max=Integer.MAX_VALUE;
		 int index=0;
		 for(int i=0;i<n;i++)
		 {
			 int k=sc.nextInt();
			 array[i]=k;
			 if(array[i]>=0)
			 {
				 array[i]=-array[i]-1;
			 }
			 if(array[i]<max)
			 {
				 max=array[i];
				 index=i;

			 }
		 }
		 if(n%2!=0)
		 {
			 array[index]=-array[index]-1;
		 }
		 for(int i=0;i<n;i++)
		 {
			 System.out.print(array[i]+" " );
		 }
	}

}


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

public class round569d2b {

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

		int n = in.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = in.nextInt();
		}
		if (n % 2 == 0) {
			for (int i = 0; i < n; i++) {
				if (arr[i] >= 0) {
					arr[i] = -1*arr[i]-1;
				}
			}
		}
		else {
			int max = Integer.MIN_VALUE;
			int maxIndex = 0;
			for (int i = 0; i < n; i++) {
				int elem = arr[i];
				if (elem < 0) {
					elem = -1*elem-1;
				}
				if (elem > max) {
					max = elem;
					maxIndex = i;
				}
			}
			for (int i = 0; i < n; i++) {
				if (i == maxIndex) {
					if (arr[i] < 0) {
						arr[i] = -1*arr[i]-1;
					}
				}
				else {
					if (arr[i] >= 0) {
						arr[i] = -1*arr[i]-1;
					}
				}
			}
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n ;i++) {
			sb.append(arr[i] + " ");

		}
		System.out.println(sb);

	}

	// ======================================================================================
	// =============================== Reference Code =======================================
	// ======================================================================================

	static int greatestDivisor(int n) {
		int limit = (int) Math.sqrt(n);
		int max = 1;
		for (int i = 2; i <= limit; i++) {
			if (n % i == 0) {
				max = Integer.max(max, i);
				max = Integer.max(max, n / i);
			}
		}
		return max;
	}

	// Method to return all primes smaller than or equal to
	// n using Sieve of Eratosthenes
	static boolean[] sieveOfEratosthenes(int n) {
		// Create a boolean array "prime[0..n]" and initialize
		// all entries it as true. A value in prime[i] will
		// finally be false if i is Not a prime, else true.
		boolean prime[] = new boolean[n + 1];
		for (int i = 0; i <= n; i++)
			prime[i] = true;

		prime[0] = false;
		prime[1] = false;

		for (int p = 2; p * p <= n; p++) {
			// If prime[p] is not changed, then it is a prime
			if (prime[p] == true) {
				// Update all multiples of p
				for (int i = p * p; i <= n; i += p)
					prime[i] = false;
			}
		}

		return prime;
	}

	// Binary search for number greater than or equal to target
	// returns -1 if number not found
	private static int bin_gteq(int[] a, int key) {
		int low = 0;
		int high = a.length;
		int max_limit = high;
		while (low < high) {
			int mid = low + (high - low) / 2;
			if (a[mid] < key) {
				low = mid + 1;
			} else
				high = mid;
		}

		return high == max_limit ? -1 : high;
	}

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

		return gcd(b % a, a);
	}

	static class Tuple<X, Y> {
		public final X x;
		public final Y y;

		public Tuple(X x, Y y) {
			this.x = x;
			this.y = y;
		}

		public String toString() {
			return "(" + x + "," + y + ")";
		}
	}

	static class Tuple3<X, Y, Z> {
		public final X x;
		public final Y y;
		public final Z z;

		public Tuple3(X x, Y y, Z z) {
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public String toString() {
			return "(" + x + "," + y + "," + z + ")";
		}
	}

	static Tuple3<Integer, Integer, Integer> gcdExtended(int a, int b, int x, int y) {
		// Base Case
		if (a == 0) {
			x = 0;
			y = 1;
			return new Tuple3(0, 1, b);
		}

		int x1 = 1, y1 = 1; // To store results of recursive call
		Tuple3<Integer, Integer, Integer> tuple = gcdExtended(b % a, a, x1, y1);
		int gcd = tuple.z;
		x1 = tuple.x;
		y1 = tuple.y;

		// Update x and y using results of recursive
		// call
		x = y1 - (b / a) * x1;
		y = x1;

		return new Tuple3(x, y, gcd);
	}

	// Returns modulo inverse of a
	// with respect to m using extended
	// Euclid Algorithm. Refer below post for details:
	// https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/
	static int inv(int a, int m) {
		int m0 = m, t, q;
		int x0 = 0, x1 = 1;

		if (m == 1)
			return 0;

		// Apply extended Euclid Algorithm
		while (a > 1) {
			// q is quotient
			q = a / m;

			t = m;

			// m is remainder now, process
			// same as euclid's algo
			m = a % m;
			a = t;

			t = x0;

			x0 = x1 - q * x0;

			x1 = t;
		}

		// Make x1 positive
		if (x1 < 0)
			x1 += m0;

		return x1;
	}

	// k is size of num[] and rem[].
	// Returns the smallest number
	// x such that:
	// x % num[0] = rem[0],
	// x % num[1] = rem[1],
	// ..................
	// x % num[k-2] = rem[k-1]
	// Assumption: Numbers in num[] are pairwise
	// coprime (gcd for every pair is 1)
	static int findMinX(int num[], int rem[], int k) {
		// Compute product of all numbers
		int prod = 1;
		for (int i = 0; i < k; i++)
			prod *= num[i];

		// Initialize result
		int result = 0;

		// Apply above formula
		for (int i = 0; i < k; i++) {
			int pp = prod / num[i];
			result += rem[i] * inv(pp, num[i]) * pp;
		}

		return result % prod;
	}

	/**
	 * Source: Matt Fontaine
	 */
	static class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int chars;

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

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

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

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

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

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

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

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

		public String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}

}


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

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

  static class CBanhMi {

    long mod = (long) (1e9 + 7);

    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt();
      int q = in.nextInt();
      long[] two = new long[n + 1];
      two[0] = 1;
      for (int i = 1; i <= n; ++i) {
        two[i] = (two[i - 1] * 2L);
        two[i] %= mod;
      }

      char[] s = in.nextCharArray();
      int[] acc = new int[n + 1];
      for (int i = 1; i <= n; ++i) {
        acc[i] = s[i - 1] == '0' ? 0 : 1;
        acc[i] += acc[i - 1];
      }
      // 0 0 1 1 | 1: 1 1 2| 2: 2 3| 4: 5| 9
      // 0 1 1 1| 1: 1 2 2| 2: 3 3| 5: 6| 11
      // 0 1 1 wwqwq| 1: 1 2 2| 3: 5 3| 8: 8| 16
      // 0 0 1 1| 1: 1 1 2| 3: 3 3| 6: 6| 12
      // 0 0 0 1| 1: 1 1 1| 2: 2 2| 4: 4| 8
      while (q-- > 0) {
        int f = in.nextInt();
        int t = in.nextInt();
        int ones = acc[t] - acc[f - 1];
        int zeros = (t - f + 1) - ones;
        if (ones == 0) {
          out.println(0);
        } else {
          long ans = two[t - f + 1] - (zeros > 0 ? two[zeros] : 0);
          if (zeros == 0) {
            --ans;
          }
          ans = (ans + mod) % mod;
          out.println(ans);
        }
      }
    }

  }

  static class InputReader implements FastIO {

    private InputStream stream;
    private static final int DEFAULT_BUFFER_SIZE = 1 << 16;
    private static final int EOF = -1;
    private byte[] buf = new byte[DEFAULT_BUFFER_SIZE];
    private int curChar;
    private int numChars;

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

    public int read() {
      if (this.numChars == EOF) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return EOF;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public int nextInt() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {
      }

      byte sgn = 1;
      if (c == 45) {
        sgn = -1;
        c = this.read();
      }

      int res = 0;

      while (c >= 48 && c <= 57) {
        res *= 10;
        res += c - 48;
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }

      throw new InputMismatchException();
    }

    public String next() {
      int c;
      while (isSpaceChar(c = this.read())) {
      }

      StringBuilder result = new StringBuilder();
      result.appendCodePoint(c);

      while (!isSpaceChar(c = this.read())) {
        result.appendCodePoint(c);
      }

      return result.toString();
    }

    public static boolean isSpaceChar(int c) {
      return c == 32 || c == 10 || c == 13 || c == 9 || c == EOF;
    }

    public char[] nextCharArray() {
      return next().toCharArray();
    }

  }

  static interface FastIO {

  }
}


import java.util.*;

public class B {

	public B () {
		int N = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int [] P = sc.nextInts();

		TreeSet<Integer> S = new TreeSet<>();
		Set<Integer> A = new HashSet<>();
		Set<Integer> B = new HashSet<>();

		for (int p : P) S.add(p);
		while (!S.isEmpty()) {
			int q = S.first();
			int x = a - q, y = b - q;
			if (S.contains(x) && S.contains(y)) {
				if (x > y) {
					S.remove(q); S.remove(x);
					A.add(q); A.add(x);
				} else {
					S.remove(q); S.remove(y);
					B.add(q); B.add(y);
				}
			}
			else if (S.contains(x)) {
				S.remove(q); S.remove(x);
				A.add(q); A.add(x);
			}
			else if (S.contains(y)) {
				S.remove(q); S.remove(y);
				B.add(q); B.add(y);
			}
			else
				exit("NO");
		}

		int [] res = new int[N];
		for (int i : rep(N))
			if (B.contains(P[i]))
				res[i] = 1;

		print("YES");
		exit(res);
	}

	private static int [] rep(int N) { return rep(0, N); }
	private static int [] rep(int S, int T) { if (T <= S) return new int [0]; int [] res = new int [T-S]; for (int i = S; i < T; ++i) res[i-S] = i; return res; }
	////////////////////////////////////////////////////////////////////////////////////
	private final static IOUtils.MyScanner sc = new IOUtils.MyScanner();
	private static void print (Object o, Object ... A) { IOUtils.print(o, A); }
	private static void exit (Object o, Object ... A) { IOUtils.print(o, A); IOUtils.exit(); }
	private static class IOUtils {
		public static class MyScanner {
			public String next() { newLine(); return line[index++]; }
			public int nextInt() { return Integer.parseInt(next()); }
			public String nextLine() { line = null; return readLine(); }
			public String [] nextStrings() { return split(nextLine()); }
			public int [] nextInts() {
				String [] L = nextStrings();
				int [] res = new int [L.length];
				for (int i = 0; i < L.length; ++i)
					res[i] = Integer.parseInt(L[i]);
				return res;
			}
			//////////////////////////////////////////////
			private boolean eol() { return index == line.length; }
			private String readLine() {
				try {
					return r.readLine();
				} catch (Exception e) {
					throw new Error (e);
				}
			}
			private final java.io.BufferedReader r;
			private MyScanner () { this(new java.io.BufferedReader(new java.io.InputStreamReader(System.in))); }
			private MyScanner (java.io.BufferedReader r) {
				try {
					this.r = r;
					while (!r.ready())
						Thread.sleep(1);
					start();
				} catch (Exception e) {
					throw new Error(e);
				}
			}
			private String [] line;
			private int index;
			private void newLine() {
				if (line == null || eol()) {
					line = split(readLine());
					index = 0;
				}
			}
			private String [] split(String s) { return s.length() > 0 ? s.split(" ") : new String [0]; }
		}
		private static String build(Object o, Object ... A) { return buildDelim(" ", o, A); }
		private static String buildDelim(String delim, Object o, Object ... A) {
			StringBuilder b = new StringBuilder();
			append(b, o, delim);
			for (Object p : A)
				append(b, p, delim);
			return b.substring(delim.length());
		}
		//////////////////////////////////////////////////////////////////////////////////
		private static void start() { if (t == 0) t = millis(); }
		private static void append(StringBuilder b, Object o, String delim) {
			if (o.getClass().isArray()) {
				int len = java.lang.reflect.Array.getLength(o);
				for (int i = 0; i < len; ++i)
					append(b, java.lang.reflect.Array.get(o, i), delim);
			} else if (o instanceof Iterable<?>)
				for (Object p : (Iterable<?>) o)
					append(b, p, delim);
			else {
				if (o instanceof Double)
					o = new java.text.DecimalFormat("#.############").format(o);
				b.append(delim).append(o);
			}
		}
		private static java.io.PrintWriter pw = new java.io.PrintWriter(System.out);
		private static void print(Object o, Object ... A) { pw.println(build(o, A)); }
		private static void err(Object o, Object ... A) { System.err.println(build(o, A)); }
		private static void exit() {
			IOUtils.pw.close();
			System.out.flush();
			err("------------------");
			err(IOUtils.time());
			System.exit(0);
		}
		private static long t;
		private static long millis() { return System.currentTimeMillis(); }
		private static String time() { return "Time: " + (millis() - t) / 1000.0; }
	}
	public static void main (String[] args) { new B(); IOUtils.exit(); }
}


/*
 * Hopefully this is AC :D
 */

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.StringTokenizer;
import java.util.Arrays;

public class TwoSets {

	static ArrayList<Integer> g[];
	static boolean visited[];
	static int ans[],p[],orig[];
	static int n,a,b;

	@SuppressWarnings("unchecked")
	public static void main(String args[] ) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter w = new PrintWriter(System.out);

	    StringTokenizer st1 = new StringTokenizer(br.readLine());
	    n = ip(st1.nextToken());
	    a = ip(st1.nextToken());
	    b = ip(st1.nextToken());

	    g = new ArrayList[n];
	    visited = new boolean[n];
	    ans = new int[n];
	    p = new int[n];
	    orig = new int[n];

	    StringTokenizer st2 = new StringTokenizer(br.readLine());
	    for(int i=0;i<n;i++){
	    	p[i] = ip(st2.nextToken());
	    	orig[i] = p[i];
	    	g[i] = new ArrayList<Integer>();
	    }

	    Arrays.sort(p);

	    boolean impossible = false;

	    for(int i=0;i<n;i++){
	    	int i1 = Arrays.binarySearch(p, a-p[i]);
	    	int i2 = Arrays.binarySearch(p, b-p[i]);
	    	if(i1 < 0 || i1 >= n)	i1 = -1;
	    	if(i2 < 0 || i2 >= n)	i2 = -1;

	    	if(i1 == -1 && i2 != -1) //if only (b-x) present then both must belong to set 1
	    		g[i].add(i2);

	    	else if(i1 != -1 && i2 == -1) //if only (a-x) present then both must belong to set 0
	    		g[i].add(i1);

	    	else if(i1 != -1 && i2 != -1){ //both present hence all 3 should be in same set,doesn't matter which
	    		g[i].add(i1);
	    		g[i].add(i2);
	    	}
	    	else{ //if none present then not possible to be in any set
	    		impossible = true;
	    		break;
	    	}
	    }

	    if(impossible){//if any element without both a-x and b-x found
	    	System.out.println("NO");
	    	return;
	    }

	    //Edge between a and b means they must be present in same set
	    //ans[i] =0 or ans[i] =1 means it must be compulsory be present in that set
	    //ans[i] = -1 means no restrictions on it's set number

	    LinkedList<Integer>	q = new LinkedList();//Queue
	    for(int i=0;i<n;i++){

	    	if(visited[i] == false){

	    		ArrayList<Integer>	curq = new ArrayList<Integer>();      //contains indices of all nodes in this connected component

	    		curq.add(i);
	    		q.add(i);
	    		visited[i] = true;

	    		while(!q.isEmpty()){
	    			int curr = q.remove();
	    			int s = g[curr].size();
	    			for(int j=0;j<s;j++){
	    				if(!visited[g[curr].get(j)]){
	    					visited[g[curr].get(j)] = true;
	    					curq.add(g[curr].get(j));
	    					q.add(g[curr].get(j));
	    				}
	    			}
	    		}

	    		boolean  found = true;

    			int s = curq.size();
	    		int temp[] = new int[s];
    			for(int j=0;j<s;j++)
    				temp[j] = p[curq.get(j)];
    			Arrays.sort(temp);

    			int anss = -1;

	    		for(int j=0;j<s;j++){
	    			int i3 = Arrays.binarySearch(temp, a - temp[j]);
	    			if(i3 < 0 || i3 >= n){
	   					found = false;
	   					break;
	   				}
	   			}

	    		if(!found){
	    			found = true;

	    			for(int j=0;j<s;j++){
		    			int i3 = Arrays.binarySearch(temp, b - temp[j]);
		   				if(i3 < 0 || i3 >= n){
		   					found = false;
		   					break;
		   				}
	    			}

	    			if(found)
	    				anss = 1;
	    			else{
	    				impossible = true;
	    				break;
	    			}

	    		}
	    		else
	    			anss = 0;

	    		for(int j=0;j<s;j++)
	    			ans[curq.get(j)] = anss;

	    	}

	    }

	    if(!impossible){
	    	w.println("YES");
    		for(int i=0;i<n;i++){
    			int i1 = Arrays.binarySearch(p, orig[i]);
    			if(ans[i1] == -1)	ans[i1] = 1;
    			w.print(ans[i1] + " ");
    		}
    		w.println();
    	}
	    else
	    	w.println("NO");

	    w.close();
	}

	public static int ip(String s){
		return Integer.parseInt(s);
	}
}


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

/**
 * Generated by Contest helper plug-in
 * Actual solution is at the bottom
 */

public class Main {
	public static void main(String[] args) {
		InputReader in = new StreamInputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		run(in, out);
	}

	public static void run(InputReader in, PrintWriter out) {
		Solver solver = new Task();
		solver.solve(1, in, out);
		Exit.exit(in, out);
	}
}

abstract class InputReader {
	private boolean finished = false;

	public abstract int read();

	public long readLong() {
		return new BigInteger(readString()).longValue();
	}

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

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

	public void setFinished(boolean finished) {
		this.finished = finished;
	}

	public abstract void close();
}

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

	public StreamInputReader(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 void close() {
		try {
			stream.close();
		} catch (IOException ignored) {
		}
	}
}

class Exit {
	private Exit() {
	}

	public static void exit(InputReader in, PrintWriter out) {
		in.setFinished(true);
		in.close();
		out.close();
	}
}

interface Solver {
	public void solve(int testNumber, InputReader in, PrintWriter out);
}

class Task implements Solver {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
		int n = in.readInt();
		int a = in.readInt();
		int b = in.readInt();

		if (a==b) {
			b = 0;
		}

		boolean[] where = new boolean[n];

		HashSet<Integer> set = new HashSet<Integer>();
		HashMap<Integer,Integer> indexmap = new HashMap<Integer,Integer>();

		for (int i = 0; i<n; i++) {
			int x = in.readInt();
			indexmap.put(x, i);
			set.add(x);
		}

		while (set.size() > 0) {
			int size = set.size();
			HashSet<Integer> todo = new HashSet<Integer>();
			HashSet<Integer> used = new HashSet<Integer>();
			for (int x : set) {
				if (used.contains(x))
					continue;
				int ax = a-x;
				int bx = b-x;

				if ((set.contains(ax) && !used.contains(ax)) && (set.contains(bx) && !used.contains(bx))) {
					todo.add(x);
				} else if (set.contains(ax) && !used.contains(ax)) {
					used.add(x);
					used.add(ax);
					todo.remove(ax);

					//chain
					bx = b-ax;
					while (set.contains(bx) && !used.contains(bx)) {
						x = bx;
						ax = a-x;
						if (!set.contains(ax) || used.contains(ax)) {
							System.out.println("NO");
							return;
						}
						todo.remove(x);
						todo.remove(ax);
						used.add(x);
						used.add(ax);
						bx = b-ax;
					}

				} else if (set.contains(bx) && !used.contains(bx)) {
					used.add(x);
					used.add(bx);
					todo.remove(bx);
					where[indexmap.get(bx)] = true;
					where[indexmap.get(x)] = true;

					//chain
					ax = a-bx;
					while (set.contains(ax) && !used.contains(ax)) {
						x = ax;
						bx = b-x;
						if (!set.contains(bx) || used.contains(bx)) {
							System.out.println("NO");
							return;
						}
						todo.remove(x);
						todo.remove(bx);
						used.add(x);
						used.add(bx);
						where[indexmap.get(bx)] = true;
						where[indexmap.get(x)] = true;
						ax = a-bx;
					}

				} else {
					System.out.println("NO");
					return;
				}
			}
			set = todo;
			if (set.size() == size) {
				System.out.println("Set size constant!!");
				break;
			}
		}

		System.out.println("YES");
		for (int i = 0; i<n; i++)
			if (where[i])
				System.out.print("1 ");
			else
				System.out.print("0 ");
	}
}

class num {

}

///


import java.io.IOException;
import java.util.Arrays;
import java.io.FilterInputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.TreeSet;
import java.io.BufferedInputStream;
import java.io.InputStream;

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

class TaskB {
    HashMap<Integer, Integer> left = new HashMap<Integer, Integer>();

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

        int[] res = new int[n];
        int[] arr = in.nextIntArray(n);

        IntDeque[] adj = IntDeque.IntDeques(n);
        boolean[] self = new boolean[n];
        boolean[] assigned = new boolean[n];

        for (int i = 0; i < n; i++) {
            left.put(arr[i], i);
        }
        for (int i = 0; i < n; i++) {
            int x = arr[i];

            boolean canA = left.containsKey(a - x);
            boolean canB = left.containsKey(b - x);
            if (!canA && !canB) {
                out.println("NO");
                return;
            }

            if (left.containsKey(a - x)) {
                self[i] |= x == a - x;
                if (x != a - x) {
                    adj[i].add(left.get(a - x));
                }
            }

            if (left.containsKey(b - x)) {
                self[i] |= x == b - x;
                if (x != b - x) {
                    adj[i].add(left.get(b - x));
                }
            }
        }

        if (a == b) {
            out.println("YES");
            out.println(IntArrayUtil.toString(res));
            return;
        }

        for (int iter = 0; iter < 2; iter++) {
            for (int i = 0; i < n; i++) {
                if (!self[i] && !assigned[i] && (iter == 1 || adj[i].size() == 1)) {
                    int u = i;
                    DFS:
                    while (true) {
                        assigned[u] = true;
                        if (self[u] && arr[u] == b - arr[u]) {
                            res[u] = 1;
                            break;
                        }
                        for (int v : adj[u]) {
                            if (!assigned[v]) {
                                assigned[v] = true;
                                if (arr[u] == b - arr[v]) {
                                    res[u] = res[v] = 1;
                                }
                                for (int newU : adj[v]) {
                                    if (!assigned[newU]) {
                                        u = newU;
                                        continue DFS;
                                    }
                                }
                                break DFS;
                            }
                        }
                        out.println("NO");
                        return;
                    }
                }
                else if (iter == 1 && !assigned[i] && adj[i].size() == 0 && arr[i] == b - arr[i]) {
                    res[i] = 1;
                }
            }
        }

        out.println("YES");
        out.println(IntArrayUtil.toString(res));
    }

}

class InputUtil {

    JoltyScanner in;

    public InputUtil(InputStream istream) {
        in = new JoltyScanner(istream);
    }

    public String next() {
        return in.next();
    }

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

    public int[] nextIntArray (int size) {
        int[] arr = new int[size];
        for (int i = 0; i < size; i++) {
            arr[i] = in.nextInt();
        }
        return arr;
    }

}

class IntDeque implements Iterable<Integer> {

    private int capacity;
    private int size = 0;
    private int front = 0;
    private int back = 0;
    private int[] deque;
    public IntDeque() {
        this(16);
    }
    public IntDeque(int capacity) {
        this.capacity = capacity;
        deque = new int[capacity];
    }
    public static IntDeque[] IntDeques(int length) {
        IntDeque[] arr = new IntDeque[length];
        for (int i = 0; i < length; i++) {
            arr[i] = new IntDeque();
        }
        return arr;
    }
    public <T extends Iterable<Integer>>IntDeque(T intList) {
        this(16);
        addAll(intList);
    }
    public IntDeque(int[] intArr) {
        this(16);
        for (int i: intArr) {
            addLast(i);
        }
    }
    public void add(int x) {
        addLast(x);
    }
    public <T extends Iterable<Integer>>void addAll(T intList) {
        for (int i: intList) {
            addLast(i);
        }
    }
    public void addLast(int x) {
        ensureCapacity();
        size++;
        deque[back++] = x;
        if (back == capacity) {
            back = 0;
        }
    }

    public void ensureCapacity() {
        if (size < capacity) {
            return;
        }
        int[] newDeque = new int[capacity << 1];
        for (int i = 0, j = front; i < size; i++, j++) {
            if (j == capacity) {
                j = 0;
            }
            newDeque[i] = deque[j];
        }
        deque = newDeque;
        capacity <<= 1;
        front = 0;
        back = size;
    }

    public Iterator<Integer> iterator() {
        return new Iterator<Integer>() {
            int done = 0;
            int curr = front;
            public boolean hasNext() {
                return done < size;
            }
            public Integer next() {
                Integer res = deque[curr++];
                if (curr == capacity) {
                    curr = 0;
                }
                done++;
                return res;
            }
            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }

    public int size() {
        return size;
    }

    public String toString() {
        if (size == 0) {
            return "";
        }
        StringBuilder res = new StringBuilder();
        for (int i: this) {
            res.append(i);
            res.append(" ");
        }
        res.setLength(res.length() - 1);
        return res.toString();
    }
}

class IntArrayUtil {

    public static String toString(int[] arr) {
        return toString(arr, " ");
    }

    public static String toString(int[] arr, String delimiter) {
        StringBuilder res = new StringBuilder();
        for (int i: arr) {
            res.append(i);
            res.append(delimiter);
        }
        res.setLength(res.length() - delimiter.length());
        return res.toString();
    }

}

class JoltyScanner {
    public static final int BUFFER_SIZE = 1 << 16;
	public static final char NULL_CHAR = (char) -1;

	StringBuilder str = new StringBuilder();
	byte[] buffer = new byte[BUFFER_SIZE];
	boolean EOF_FLAG = false;
	int bufferIdx = 0, size = 0;
	char c = NULL_CHAR;
	BufferedInputStream in;

	public JoltyScanner(InputStream in) {
		this.in = new BufferedInputStream(in, BUFFER_SIZE);
	}

	public int nextInt() {
		long x = nextLong();
		if (x > Integer.MAX_VALUE || x < Integer.MIN_VALUE) {
			throw new ArithmeticException("Scanned value overflows integer");
		}
		return (int) x;
	}

	public long nextLong() {
		boolean negative = false;
		if (c == NULL_CHAR) {
			c = nextChar();
		}
		for (; !EOF_FLAG && (c < '0' || c > '9'); c = nextChar()) {
			if (c == '-') {
				negative = true;
			}
		}
		checkEOF();
		long res = 0;
		for (; c >= '0' && c <= '9'; c = nextChar()) {
			res = (res << 3) + (res << 1) + c - '0';
		}
		return negative ? -res : res;
	}

    public String next() {
		checkEOF();
		if (c == NULL_CHAR) {
			c = nextChar();
		}
		while (Character.isWhitespace(c)) {
			c = nextChar();
			checkEOF();
		}
		str.setLength(0);
		for (; !EOF_FLAG && !Character.isWhitespace(c); c = nextChar()) {
			str.append(c);
		}
		return str.toString();
	}

    public char nextChar() {
		if (EOF_FLAG) {
			return NULL_CHAR;
		}
		while (bufferIdx == size) {
			try {
				size = in.read(buffer);
				if (size == -1) {
					throw new Exception();
				}
			} catch (Exception e) {
				EOF_FLAG = true;
				return NULL_CHAR;
			}
			if (size == -1) {
				size = BUFFER_SIZE;
			}
			bufferIdx = 0;
		}
		return (char) buffer[bufferIdx++];
	}

    public void checkEOF() {
		if (EOF_FLAG) {
			throw new EndOfFileException();
		}
	}

	public class EndOfFileException extends RuntimeException {
	}
}


import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * 4 4
 * 1 5 3 4
 * 1 2
 * 1 3
 * 2 3
 * 3 3
 *
 *
 * @author pttrung
 */
public class A {

    public static long Mod = (long) (1e9 + 7);
    public static long[][] dp;

    public static void main(String[] args) throws FileNotFoundException {

        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        int[] data = new int[n];
        int[]u = new int[n];
        int[]s = new int[n];
        HashMap<Integer, Integer> map = new HashMap();

        for(int i = 0; i < n; i++){
            u[i] = i;
            data[i] = in.nextInt();
            map.put(data[i], i);
        }
        boolean ok = true;
        boolean[]check = new boolean[n];
        for(int i = 0; i < n; i++){
            if(map.containsKey(a - data[i])){
                u[find(i, u)]= u[find(map.get(a- data[i]), u)];
                s[i] |= 1;
            }
            if(map.containsKey(b - data[i])){
                u[find(i, u)]= u[find(map.get(b- data[i]), u)];
                s[i] |= 2;
            }

        }
        int[]g = new int[n];
        Arrays.fill(g,3);
        for(int i = 0;  i< n; i++){
            if(s[i] == 0){
                ok = false;
                break;
            }
            g[find(i, u)] &= s[i];
            if(g[find(i,u)] == 0){
                ok = false;
                break;
            }
        }
        //System.out.println(Arrays.toString(g));
        if(ok){
            out.println("YES");
            for(int i = 0; i < n; i++){
                if((g[find(i,u)] & 1) == 0){
                    out.print(1 + " ");
                }else{
                    out.print(0 + " ");
                }
            }
        }else{
            out.println("NO");
        }

        out.close();
    }

    static int find(int index, int[]u){
        if(index != u[index]){
            return u[index] = find(u[index], u);
        }
        return index;
    }

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

    public static int[][] powSquareMatrix(int[][] A, long p) {
        int[][] unit = new int[A.length][A.length];
        for (int i = 0; i < unit.length; i++) {
            unit[i][i] = 1;
        }
        if (p == 0) {
            return unit;
        }
        int[][] val = powSquareMatrix(A, p / 2);
        if (p % 2 == 0) {
            return mulMatrix(val, val);
        } else {
            return mulMatrix(A, mulMatrix(val, val));
        }

    }

    public static int[][] mulMatrix(int[][] A, int[][] B) {
        int[][] result = new int[A.length][B[0].length];
        for (int i = 0; i < result.length; i++) {
            for (int j = 0; j < result[0].length; j++) {
                long temp = 0;
                for (int k = 0; k < A[0].length; k++) {

                    temp += ((long) A[i][k] * B[k][j] % Mod);
                    temp %= Mod;
                }
                temp %= Mod;
                result[i][j] = (int) temp;
            }
        }

        return result;
    }

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

    }

    static class FT {

        int[] data;

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

        void update(int index, int val) {
            // System.out.println("UPDATE INDEX " + index);
            while (index < data.length) {
                data[index] += val;
                index += index & (-index);

                //    System.out.println("NEXT " +index);
            }
        }

        int get(int index) {
            //  System.out.println("GET INDEX " + index);
            int result = 0;
            while (index > 0) {
                result += data[index];
                index -= index & (-index);
                // System.out.println("BACK " + index);
            }
            return result;
        }
    }

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

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

            return val * val % Mod;
        } else {
            return (val * val % Mod) * a % Mod;
        }
    }

//    static Point intersect(Point a, Point b, Point c) {
//        double D = cross(a, b);
//        if (D != 0) {
//            return new Point(cross(c, b) / D, cross(a, c) / D);
//        }
//        return null;
//    }
//
//    static Point convert(Point a, double angle) {
//        double x = a.x * cos(angle) - a.y * sin(angle);
//        double y = a.x * sin(angle) + a.y * cos(angle);
//        return new Point(x, y);
//    }
    static Point minus(Point a, Point b) {
        return new Point(a.x - b.x, a.y - b.y);
    }
//
//    static Point add(Point a, Point b) {
//        return new Point(a.x + b.x, a.y + b.y);
//    }
//

    /**
     * Cross product ab*ac
     *
     * @param a
     * @param b
     * @param c
     * @return
     */
    static double cross(Point a, Point b, Point c) {
        Point ab = new Point(b.x - a.x, b.y - a.y);
        Point ac = new Point(c.x - a.x, c.y - a.y);
        return cross(ab, ac);
    }

    static double cross(Point a, Point b) {
        return a.x * b.y - a.y * b.x;
    }

    /**
     * Dot product ab*ac;
     *
     * @param a
     * @param b
     * @param c
     * @return
     */
    static long dot(Point a, Point b, Point c) {
        Point ab = new Point(b.x - a.x, b.y - a.y);
        Point ac = new Point(c.x - a.x, c.y - a.y);
        return dot(ab, ac);
    }

    static long dot(Point a, Point b) {
        long total = a.x * b.x;
        total += a.y * b.y;
        return total;
    }

    static double dist(Point a, Point b) {
        long total = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
        return Math.sqrt(total);
    }

    static long norm(Point a) {
        long result = a.x * a.x;
        result += a.y * a.y;
        return result;
    }

    static double dist(Point a, Point b, Point x, boolean isSegment) {
        double dist = cross(a, b, x) / dist(a, b);
        // System.out.println("DIST " + dist);

        if (isSegment) {
            Point ab = new Point(b.x - a.x, b.y - a.y);

            long dot1 = dot(a, b, x);
            long norm = norm(ab);
            double u = (double) dot1 / norm;
            if (u < 0) {
                return dist(a, x);
            }

            if (u > 1) {
                return dist(b, x);
            }
        }
        return Math.abs(dist);

    }

    static long squareDist(Point a, Point b) {
        long x = a.x - b.x;
        long y = a.y - b.y;
        return x * x + y * y;
    }

    static class Point {

        int x, y;

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

        @Override
        public String toString() {
            return "Point{" + "x=" + x + ", y=" + y + '}';
        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            //System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //br = new BufferedReader(new FileReader(new File("A-large (2).in")));
        }

        public String next() {

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

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

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

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

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

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


import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	static int n;
	static int a;
	static int b;
	static int g;
	static int ref;
	static int refg;
	static HashSet<Integer> cgroup;
	static HashMap<Integer,Integer> indexmap;
	static HashSet<Integer> nums;
	static HashSet<Integer> used;

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

		boolean[] where = new boolean[n];
		indexmap = new HashMap<Integer,Integer>();
		used = new HashSet<Integer>();
		nums = new HashSet<Integer>();

		if (a==b)
			b = 0;

		for (int i = 0; i<n; i++) {
			int x = scan.nextInt();
			nums.add(x);
			indexmap.put(x,i);
		}
		scan.close();

		for (int x : nums) {
			if (used.contains(x))
				continue;
			cgroup = new HashSet<Integer>();
			cgroup.add(x);
			g = -1;
			refg = -1;
			ref = -1;
			used.add(x);
			if (!spawn(x,a,b) || !spawn(x,b,a)) {
				System.out.println("NO");
				return;
			}
			if (cgroup.size()%2==1 && ref == -1) {
				System.out.println("NO");
				return;
			} else {
				boolean w = true;
				if (g == a)
					w = false;
				for (int k : cgroup) {
					where[indexmap.get(k)] = w;
				}
			}
		}

		System.out.println("YES");
		for (int i = 0; i<where.length; i++)
			if (where[i])
				System.out.print("1 ");
			else
				System.out.print("0 ");

	}

	private static boolean spawn(int x, int ab, int abo) {
		int xab = ab-x;
		if (xab == x) {
			ref = x;
			refg = ab;
		} else {
			if (nums.contains(xab)) {
				cgroup.add(xab);
				used.add(xab);
				spawn(xab,abo,ab);
			} else {
				if (g == -1)
					g = abo;
				else if (g != abo) {
					return false;
				}
			}
		}
		return true;
	}

}


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

public class B {

    void solve() throws IOException {
        in = new InputReader("__std");
        out = new OutputWriter("__std");

        int n = in.readInt();
        int a = in.readInt();
        int b = in.readInt();
        int ma = 0;
        int mb = 1;
        if (a < b) {
            int t = a; a = b; b = t;
            t = ma; ma = mb; mb = t;
        }
        final int[] p = new int[n];
        Integer id[] = new Integer[n];
        Map<Integer, Integer> pos = new HashMap<Integer, Integer>();
        for (int i = 0; i < n; ++i) {
            p[i] = in.readInt();
            id[i] = i;
            pos.put(p[i], i);
        }
        Arrays.sort(id, new Comparator<Integer>() {
            public int compare(Integer i, Integer j) {
                return p[i] - p[j];
            }
        });
        int[] mask = new int[n];
        Arrays.fill(mask, -1);
        boolean flag = true;
        for (int i = 0; i < n && flag; ++i) {
            if (mask[id[i]] == -1) {
                if (p[id[i]] < a) {
                    if (pos.containsKey(a - p[id[i]])) {
                        int j = pos.get(a - p[id[i]]);
                        if (mask[j] != mb) {
                            mask[id[i]] = mask[j] = ma;
                            continue;
                        }
                    }
                    if (p[id[i]] < b && pos.containsKey(b - p[id[i]])) {
                        int j = pos.get(b - p[id[i]]);
                        if (mask[j] != ma) {
                            mask[id[i]] = mask[j] = mb;
                            continue;
                        }
                    }
                }
                flag = false;
            }
        }
        if (flag) {
            out.println("YES");
            for (int m : mask) {
                out.print(m + " ");
            }
        } else {
            out.println("NO");
        }

        exit();
    }

    void exit() {
        //System.err.println((System.currentTimeMillis() - startTime) + " ms");
        out.close();
        System.exit(0);
    }

    InputReader in;
    OutputWriter out;

    //long startTime = System.currentTimeMillis();

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

    class InputReader {

        private InputStream stream;

        private byte[] buffer = new byte[1024];
        private int pos, len;

        private int cur;

        private StringBuilder sb = new StringBuilder(32);

        InputReader(String name) throws IOException {
            if (name.equals("__std")) {
                stream = System.in;
            } else {
                stream = new FileInputStream(name);
            }
            cur = read();
        }

        private int read() throws IOException {
            if (len == -1) {
                throw new EOFException();
            }
            if (pos >= len) {
                pos = 0;
                len = stream.read(buffer);
                if (len == -1) return -1;
            }
            return buffer[pos++];
        }

        char readChar() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            char res = (char) cur;
            cur = read();
            return res;
        }

        int readInt() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            while (whitespace()) {
                cur = read();
            }
            if (cur == -1) {
                throw new EOFException();
            }
            int sign = 1;
            if (cur == '-') {
                sign = -1;
                cur = read();
            }
            int res = 0;
            while (!whitespace()) {
                if (cur < '0' || cur > '9') {
                    throw new NumberFormatException();
                }
                res *= 10;
                res += cur - '0';
                cur = read();
            }
            return res * sign;
        }

        long readLong() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            return Long.parseLong(readToken());
        }

        double readDouble() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            return Double.parseDouble(readToken());
        }

        String readLine() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            sb.setLength(0);
            while (cur != -1 && cur != '\r' && cur != '\n') {
                sb.append((char) cur);
                cur = read();
            }
            if (cur == '\r') {
                cur = read();
            }
            if (cur == '\n') {
                cur = read();
            }
            return sb.toString();
        }

        String readToken() throws IOException {
            if (cur == -1) {
                throw new EOFException();
            }
            while (whitespace()) {
                cur = read();
            }
            if (cur == -1) {
                throw new EOFException();
            }
            sb.setLength(0);
            while (!whitespace()) {
                sb.append((char) cur);
                cur = read();
            }
            return sb.toString();
        }

        boolean whitespace() {
            return cur == ' ' || cur == '\t' || cur == '\r' || cur == '\n' || cur == -1;
        }

        boolean eof() {
            return cur == -1;
        }
    }

    class OutputWriter {

        private PrintWriter writer;

        OutputWriter(String name) throws IOException {
            if (name.equals("__std")) {
                writer = new PrintWriter(System.out);
            } else {
                writer = new PrintWriter(name);
            }
        }

        void print(String format, Object ... args) {
            writer.print(new Formatter(Locale.US).format(format, args));
        }

        void println(String format, Object ... args) {
            writer.println(new Formatter(Locale.US).format(format, args));
        }

        void print(Object value) {
            writer.print(value);
        }

        void println(Object value) {
            writer.println(value);
        }

        void println() {
            writer.println();
        }

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


import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;

/**
 * Created by hama_du on 2014/09/21.
 */
public class ProblemB {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        long a = in.nextLong();
        long b = in.nextLong();
        long[] x = new long[n];
        for (int i = 0; i < n; i++) {
            x[i] = in.nextLong();
        }

        Map<Long,Integer> idxmap = new HashMap<>();
        for (int i = 0; i < n; i++) {
            idxmap.put(x[i], i);
        }
        if (a == b) {
            solve1(x, a, idxmap, out);
            return;
        }

        int[] mark = new int[n];
        Arrays.fill(mark, -1);
        boolean isok = true;
        for (int i = 0 ; i < n ; i++) {
            if (mark[i] != -1) {
                continue;
            }
            long w = x[i];
            long aw = a - w;
            long bw = b - w;
            if (idxmap.containsKey(aw) && idxmap.containsKey(bw)) {
                continue;
            } else if (idxmap.containsKey(bw)) {
                long w1 = w;
                long w2 = bw;
                while (true) {
                    if (!idxmap.containsKey(w1) || !idxmap.containsKey(w2)) {
                        break;
                    }
                    int i1 = idxmap.get(w1);
                    int i2 = idxmap.get(w2);
                    if (mark[i1] == 0 || mark[i2] == 0) {
                        isok = false;
                    }
                    mark[i1] = 1;
                    mark[i2] = 1;
                    if (w1 + a - b == w2) {
                        break;
                    }
                    w1 += (a - b);
                    w2 += (b - a);
                }
            } else if (idxmap.containsKey(aw)){
                long w1 = w;
                long w2 = aw;
                while (true) {
                    if (!idxmap.containsKey(w1) || !idxmap.containsKey(w2)) {
                        break;
                    }
                    int i1 = idxmap.get(w1);
                    int i2 = idxmap.get(w2);
                    if (mark[i1] == 1 || mark[i2] == 1) {
                        isok = false;
                    }
                    mark[i1] = 0;
                    mark[i2] = 0;
                    if (w1 + b - a == w2) {
                        break;
                    }
                    w1 += (b - a);
                    w2 += (a - b);
                }
            }
        }
        for (int i = 0 ; i < n ; i++) {
            if (mark[i] == -1) {
                isok = false;
                break;
            }
        }
        if (isok) {
            printAnswer(mark, out);
        } else {
            out.println("NO");
        }
        out.flush();
    }

    private static void printAnswer(int[] mark, PrintWriter out) {
        out.println("YES");
        StringBuilder ln = new StringBuilder();
        for (int m : mark) {
            ln.append(' ').append(m);
        }
        out.println(ln.substring(1));
    }

    private static void solve1(long[] x, long a, Map<Long, Integer> idxmap, PrintWriter out) {
        int[] mark = new int[x.length];
        for (int i = 0 ; i < x.length ; i++) {
            if (mark[i] == 1) {
                continue;
            }
            long w = x[i];
            long wp = a - w;
            if (idxmap.containsKey(wp)) {
                mark[i] = mark[idxmap.get(wp)] = 1;
            }
        }
        boolean isok = true;
        for (int i = 0 ; i < x.length ; i++) {
            if (mark[i] == 0) {
                isok = false;
                break;
            }
        }
        if (isok) {
            printAnswer(mark, out);
        } else {
            out.println("NO");
        }
        out.flush();
    }

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

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

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

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

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

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

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


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

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

class TaskB {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.readInt();
        int a = in.readInt();
        int b = in.readInt();
        TreeMap<Integer, Integer> mp = new TreeMap<Integer, Integer>();
        for (int i = 0; i < n; ++i) {
            mp.put(in.readInt(), i);
        }
        int aname = 0;
        int bname = 1;
        if (a > b) {
            int t = a;
            a = b;
            b = t;
            aname = 1;
            bname = 0;
        }
        int[] res = new int[n];
        while (mp.size() > 0) {
            Map.Entry<Integer, Integer> e = mp.firstEntry();
            int val = e.getKey();
            if (mp.containsKey(b - val)) {
                res[mp.get(val)] = res[mp.get(b - val)] = bname;
                mp.remove(val);
                mp.remove(b - val);
            } else if (mp.containsKey(a - val)) {
                res[mp.get(val)] = res[mp.get(a - val)] = aname;
                mp.remove(val);
                mp.remove(a - val);
            } else {
                break;
            }
        }
        if (mp.size() > 0) {
            out.println("NO");
        } else {
            out.println("YES");
            for (int i = 0; i < n; ++i) {
                if (i > 0) out.print(" ");
                out.print(res[i]);
            }
            out.println();
        }
    }
}

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() {
        // InputMismatchException -> UnknownError
        if (numChars == -1)
            throw new UnknownError();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new UnknownError();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        } else if (c == '+') {
            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 static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

}


import java.util.Map;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Set;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.HashSet;
import java.io.InputStream;

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

class TaskB {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; ++i)
            p[i] = in.nextInt();
        Map<Integer, Integer> position = new HashMap<>(n);
        for (int i = 0; i < n; ++i)
            position.put(p[i], i);
        DisjointSet sets = new DisjointSet(n);
        for (int i = 0; i < n; ++i) {
            if (position.containsKey(a - p[i]))
                sets.joinSet(i, position.get(a - p[i]));
            if (position.containsKey(b - p[i]))
                sets.joinSet(i, position.get(b - p[i]));
        }
        Group[] groups = new Group[n];
        for (int i = 0; i < n; ++i)
            if (sets.getSet(i) == i)
                groups[i] = new Group();
        for (int i = 0; i < n; ++i)
            groups[sets.getSet(i)].value.add(p[i]);
        int[] answer = new int[n];
        for (Group group : groups) if (group != null) {
            if (group.check(a)) {
                for (int key : group.value)
                    answer[position.get(key)] = 0;
            } else if (group.check(b)) {
                for (int key : group.value)
                    answer[position.get(key)] = 1;
            } else {
                out.println("NO");
                return;
            }
        }
        out.println("YES");
        for (int i = 0; i < n; ++i) {
            if (i > 0) out.print(' ');
            out.print(answer[i]);
        }
        out.println();
    }

    class Group {
        Set<Integer> value = new HashSet<>();

        boolean check(int sum) {
            for (int key : value)
                if (!value.contains(sum - key))
                    return false;
            return true;
        }
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(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());
    }

}

class DisjointSet {
    private final int[] label;
    private int numSets;
    private Listener listener;

    public DisjointSet(int n, Listener listener) {
        label = new int[n];
        Arrays.fill(label, -1);
        numSets = n;
        this.listener = listener;
    }

    public DisjointSet(int n) {
        this(n, null);
    }

    public int getSet(int at) {
        if (label[at] < 0) return at;
        return label[at] = getSet(label[at]);
    }

    public boolean sameSet(int u, int v) {
        return getSet(u) == getSet(v);
    }

    public boolean joinSet(int u, int v) {
        if (sameSet(u, v)) return false;
        u = getSet(u);
        v = getSet(v);
        if (label[u] < label[v]) {
            int tmp = u;
            u = v;
            v = tmp;
        }
        label[v] += label[u];
        label[u] = v;
        --numSets;
        if (listener != null) listener.joined(u, v);
        return true;
    }

    public static interface Listener {
        public void joined(int joinedRoot, int root);
    }
}


import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.Set;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.HashSet;
import java.io.InputStream;

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

class TaskD {
    public void solve(int testNumber, InputReader jin, OutputWriter jout) {
        int n = jin.int32();
        int a = jin.int32();
        int b = jin.int32();

        Set<Integer> present = new HashSet<Integer>();
        int[] arr = new int[n];
        int[] sarr = new int[n];
        for(int i = 0; i < n; i++) {
            sarr[i] = arr[i] = jin.int32();
            present.add(arr[i]);
        }

        boolean rev = b < a;
        if(b < a) {b ^= a; a ^= b; b ^= a; }

        Arrays.sort(sarr);

        Set<Integer> set1 = new HashSet<Integer>();
        Set<Integer> set2 = new HashSet<Integer>();

        for(int i = 0; i < n; i++) {
            if(set1.contains(sarr)) continue;
            if(set2.contains(sarr)) continue;
            int comp1 = b - sarr[i];
            if(present.contains(comp1)) {
                set2.add(sarr[i]);
                set2.add(comp1);
                present.remove(comp1);
            } else {
                int comp2 = a - sarr[i];
                if(present.contains(comp2)) {
                    set1.add(sarr[i]);
                    set1.add(comp2);
                    present.remove(comp2);
                } else {
                    jout.println("NO");
                    return;
                }
            }
        }

        jout.println("YES");
        for(int i = 0; i < n; i++) {
            if(i != 0) jout.print(' ');
            if(rev) jout.print(set2.contains(arr[i])? 0 : 1);
            else jout.print(set1.contains(arr[i])? 0 : 1);
        }
    }
}

class InputReader {
    private static final int bufferMaxLength = 1024;
    private InputStream in;
    private byte[] buffer;
    private int currentBufferSize;
    private int currentBufferTop;
    private static final String tokenizers = " \t\r\f\n";

    public InputReader(InputStream stream) {
        this.in = stream;
        buffer = new byte[bufferMaxLength];
        currentBufferSize = 0;
        currentBufferTop = 0;
    }

    private boolean refill() {
        try {
            this.currentBufferSize = this.in.read(this.buffer);
            this.currentBufferTop = 0;
        } catch(Exception e) {}
        return this.currentBufferSize > 0;
    }

    private Byte readChar() {
        if(currentBufferTop < currentBufferSize) {
            return this.buffer[this.currentBufferTop++];
        } else {
            if(!this.refill()) {
                return null;
            } else {
                return readChar();
            }
        }
    }

    public String token()  {
        StringBuffer tok = new StringBuffer();
        Byte first;
        while((first = readChar()) != null && (tokenizers.indexOf((char) first.byteValue()) != -1));
        if(first == null) return null;
        tok.append((char)first.byteValue());
        while((first = readChar()) != null && (tokenizers.indexOf((char) first.byteValue()) == -1)) {
            tok.append((char)first.byteValue());
        }
        return tok.toString();
    }

    public Integer int32() throws NumberFormatException {
        String tok = token();
        return tok == null? null : Integer.parseInt(tok);
    }

    }

class OutputWriter {
    private final int bufferMaxOut = 1024;
    private PrintWriter out;
    private StringBuilder output;
    private boolean forceFlush = false;

    public OutputWriter(OutputStream outStream) {
        out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outStream)));
        output = new StringBuilder(2 * bufferMaxOut);
    }

    public OutputWriter(Writer writer) {
        forceFlush = true;
        out = new PrintWriter(writer);
        output = new StringBuilder(2 * bufferMaxOut);
    }

    private void autoFlush() {
        if(forceFlush || output.length() >= bufferMaxOut) {
            flush();
        }
    }

    public void print(Object... tokens) {
        for(int i = 0; i < tokens.length; i++) {
            if(i != 0) output.append(' ');
            output.append(tokens[i]);
        }
        autoFlush();
    }

    public void println(Object... tokens) {
        print(tokens);
        output.append('\n');
        autoFlush();
    }

    public void flush() {
        out.print(output);
        output.setLength(0);
    }

    public void close() {
        flush();
        out.close();
    }
}


import java.io.*;
import java.util.*;
public class CF_468B {
    public static void main(String[] args) throws IOException {
        new CF_468B().solve();
    }

    int root(int[] father, int a){
        if (father[a]==a) return a;
        else return father[a]=root(father, father[a]);
    }
    void unite(int[] father, int a, int b){
        father[root(father, a)]=root(father, b);
    }

    private void solve() throws IOException{

        InputStream in = System.in;
        PrintStream out = System.out;

//        in = new FileInputStream("in.txt");
//        out = new PrintStream("out.txt");

        long mod=1_000_000_007;
        Scanner sc=new Scanner(in);
        int n=sc.nextInt();
        long a=sc.nextLong(), b=sc.nextLong();

        int[] father=new int[n];
        long[] p=new long[n];
        HashMap<Long, Integer> pos=new HashMap<Long, Integer>();
        for (int i=0;i<n;i++){
            father[i]=i;
            p[i]=sc.nextLong();
            pos.put(p[i],i);
        }
        for (int i=0;i<n;i++){
            if (pos.containsKey(a-p[i])) unite(father,i,pos.get(a-p[i]) );
            if (pos.containsKey(b-p[i])) unite(father,i,pos.get(b-p[i]) );
        }
        boolean[] canA=new boolean[n],
                canB=new boolean[n];
        Arrays.fill(canA,true);
        Arrays.fill(canB,true);
        for (int i=0;i<n;i++){
            if (!pos.containsKey(a-p[i]) ||
                    root(father, i)!=root(father, pos.get(a-p[i])))
                canA[root(father, i)]=false;
            if (!pos.containsKey(b-p[i]) ||
                    root(father, i)!=root(father, pos.get(b-p[i])))
                canB[root(father, i)]=false;
            if (!canA[root(father,i)] && !canB[root(father,i)]){
                out.println("NO");
                return;
            }
        }
        out.println("YES");
        for (int i=0;i<n;i++)
            if (canA[root(father, i)])
                out.print("0 ");
            else
                out.print("1 ");

    }
}