import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

public class Main {
	FastScanner in;
	PrintWriter out;
	boolean systemIO = true;

	public class Pair {
		int x;
		int y;

		public Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}
	
	public class Edge {
		int x;
		int y;
		int n;
		
		public Edge(int x, int y, int n) {
			this.x = x;
			this.y = y;
			this.n = n;
		}
	}
	
	boolean[] good;

	public void solve() {
		int n = in.nextInt();
		int m = in.nextInt();
		String s = in.next();
		good = new boolean[n];
		int[] toA = new int[n];
		int[] toB = new int[n];
		boolean[] type = new boolean[n];
		for (int i = 0; i < type.length; i++) {
			type[i] = s.charAt(i) == 'A';
		}
		ArrayList<Edge>[] e = new ArrayList[n];
		for (int i = 0; i < e.length; i++) {
			e[i] = new ArrayList<>();
		}
		for (int i = 0; i < m; i++) {
			int x = in.nextInt() - 1;
			int y = in.nextInt() - 1;
			e[x].add(new Edge(x, y, i));
			if (type[y]) {
				toA[x]++;
			} else {
				toB[x]++;
			}
			if (x != y) {
				e[y].add(new Edge(y, x, i));
				if (type[x]) {
					toA[y]++;
				} else {
					toB[y]++;
				}
			}
		}
		Queue<Integer> q = new ArrayDeque<>();
		int sz = 0;
		for (int i = 0; i < e.length; i++) {
			if (toA[i] > 0 && toB[i] > 0) {
				good[i] = true;
				sz++;
			} else {
				good[i] = false;
				q.add(i);
			}
		}
		while (!q.isEmpty()) {
			int x = q.poll();
			for (Edge edge : e[x]) {
				if (good[edge.y]) {
					if (type[x]) {
						toA[edge.y]--;
					} else {
						toB[edge.y]--;
					}
					if (toA[edge.y] * toB[edge.y] == 0) {
						sz--;
						good[edge.y] = false;
						q.add(edge.y);
					}
				}
			}
		}
		if (sz > 0) {
			out.println("Yes");
		} else {
			out.println("No");
		}
	}

	public void run() {
		try {
			if (systemIO) {
				in = new FastScanner(System.in);
				out = new PrintWriter(System.out);
			} else {
				in = new FastScanner(new File("input.txt"));
				out = new PrintWriter(new File("output.txt"));
			}
			solve();

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

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

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

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

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

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

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

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

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

	}

	// AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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