#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

template<class T> ostream& operator<<(ostream& os, const V<T> &v) {
    cout << "[";
    for (auto p: v) cout << p << ", ";
    cout << "]";
    return os;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << fixed;
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    V<int> d(n);
    for (int i = 0; i < n; i++) d[i] = s[i] - 'A';

    VV<int> g(n);
    V<array<int, 2>> c(n);
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v; u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
        c[u][d[v]]++;
        c[v][d[u]]++;
    }

    queue<int> q;
    for (int i = 0; i < n; i++) {
        if (c[i][0] == 0 || c[i][1] == 0) q.push(i);
    }

    V<bool> used(n);
    int uc = 0;
    while (q.size()) {
        int p = q.front(); q.pop();
        if (used[p]) continue;
        used[p] = true;
        uc++;
        int x = d[p];
        for (int v: g[p]) {
            c[v][x]--;
            if (c[v][x] == 0) q.push(v);
        }
    }
    cout << (uc == n ? "No" : "Yes") << endl;
    return 0;
}
