#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define REP(i,k,n) for(ll i=k;i<ll(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define UNIQUE(a) sort(all(a));a.erase(unique(all(a)),a.end())
#define decimal cout<<fixed<<setprecision(10)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)
using ll=long long;
using P=pair<ll,ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
constexpr ll inf=1001001001001001;
constexpr int INF=1001001001;
constexpr int mod=3;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
void YesNo(bool b){if(b)out("Yes");else out("No");}
void yesno(bool b){if(b)out("yes");else out("no");}
void YESNO(bool b){if(b)out("YES");else out("NO");}
ll modpow(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%mod;}a=a*a%mod;b>>=1;}return c;}
vi calc(ll x){vi v;while(x>0){v.eb(x%10);x/=10;}reverse(all(v));return v;}

ll bb(char c){
    if(c=='B') return 0;
    if(c=='W') return 1;
    if(c=='R') return 2;
}

vi v(410000),cnt(410000);

void init(ll n){
    v[1]=1,cnt[1]=0;
    REP(i,2,n+5){
        if(i%3==0){
            ll j=i,c=0;
            while(j%3==0){j/=3; c++;}
            v[i]=v[i-1]*j%3;
            cnt[i]=cnt[i-1]+c;
        }
        else{
            v[i]=v[i-1]*i%3;
            cnt[i]=cnt[i-1];
        }
    }
}

ll COM(ll n,ll r){
    if(r==0||n==r) return 1;
    else if(cnt[n]>cnt[r]+cnt[n-r]) return 0;
    else{
        ll a=v[n],b=v[r]*v[n-r]%3;
        if(a==b) return 1;
        else return 2;
    }
}

int main(){
    ll n; cin>>n;
    init(n);
    string c;
    cin>>c;
    ll sum=0;
    rep(i,n){
        if(i>n-i-1) break;
        sum+=bb(c[i])*COM(n-1,i)%mod;
        sum%=mod;
        //out(sum);
        if(i<n-i-1) sum+=bb(c[n-1-i])*COM(n-1,i)%mod;
        sum%=mod;
        //out(sum);
    }
    ll ans;
    if(n%2==0) ans=(3-sum)%3;
    else ans=sum;
    if(ans==0) out("B");
    else if(ans==1) out("W");
    else out("R");
    /*REP(i,1,10){
      rep(j,i+1) cout<<COM(i,j);
      cout<<endl;
    }*/
}
#include<iostream>
#include<iterator>
#include<algorithm>
#include<climits>
#include<map>
#include<set>
#include<cmath>
#include<numeric>
#include<string>
#include<sstream>
#include<cstdio>
#include<vector>
#include<bitset>
// #include <atcoder/segtree>
#define ll long long
using namespace std;


int main()
{
    ll n, m;
    cin >> n >> m;
    ll a[101] = {0};
    ll b[101] = {0};
    for(int i = 1; i <= m; ++i){
        cin >> a[i] >> b[i];
    }
    ll k;
    cin >> k;
    ll c[17] = {0};
    ll d[17] = {0};
    for(int i = 1; i <= k; ++i){
        cin >> c[i] >> d[i];
    }
    unsigned long long pow2k = (unsigned long long)pow(2,k);
    ll max_meet_count = 0;
    for (unsigned long long i = 0; i < pow2k; ++i){
        ll dish[101] = {0};
        bitset<64> bs(i);
        for(int shift=0; shift<k; ++shift){
            bool valid = (i>>shift)&1ull;
            
            if (valid){
                dish[c[shift+1]]+=1;
            }else{
                dish[d[shift+1]]+=1;
            }
        }
        ll meet_count = 0;
        for(int j = 1; j <= m; ++j){
            if (dish[a[j]] > 0 && dish[b[j]] > 0){
                ++meet_count;
            }
        }
        if (max_meet_count < meet_count){
            max_meet_count = meet_count;
        }
        
    }
    cout << max_meet_count << endl;
}