#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define printl(v) for (auto it : v) printf("%lld ", it); puts("");

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll L, N, M;
    cin >> L >> N >> M;
    ll N_U =0, N_R=0;
    vector<ll> A_U;
    for(ll i=0;i<N;i++){
        char type;
        ll C;
        cin >> type >> C;
        if(type == 'U'){
            N_U++;
            A_U.push_back(C);
        }
        else{
            N_R++;
        }
    }
    ll M_U =0, M_L=0;
    vector<ll> B_U;
    for(ll i=0;i<M;i++){
        char type;
        ll C;
        cin >> type >> C;
        if(type == 'U'){
            M_U++;
            B_U.push_back(C);
        }
        else{
            M_L++;
        }
    }
    // Sort A_U and B_U
    sort(A_U.begin(), A_U.end());
    sort(B_U.begin(), B_U.end());
    for(auto&it:B_U)
    cout<<it<<" ";
    cout<<endl;
    // Count K: number of C in both A_U and B_U
    ll K=0;
    size_t a=0, b_idx=0;
    while(a < A_U.size() && b_idx < B_U.size()){
        if(A_U[a] == B_U[b_idx]){
            K++;
            a++;
            b_idx++;
        }
        else if(A_U[a] < B_U[b_idx]){
            a++;
        }
        else{
            b_idx++;
        }
    }
    // Compute I
    ll I = N_U * M_L + N_R * M_U + N_R * M_L - K;
    // Compute boundary_segments
    ll boundary_segments = M_L + N_U + M_U + N_R + 4;
    // Compute beam_segments
    ll beam_segments = N_U * (M_L +1) + N_R * (M_L + M_U +1) + M_U * (N_R +1) + M_L * (N_U + N_R +1);
    // Compute E
    ll E = boundary_segments + beam_segments;
    // Compute V
    ll V = 4 + N + M + I;
    // Compute F
    ll F;
    //cout<<E<<" "<<V<<endl;
    if(N >0 && M >0){
        F = E - V + 2;
    }
    else{
        F = E - V + 1;
    }
    cout << F;
}
