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

#define int long long

int w, h, n;
int x[200010];
int y[200010];
char d[200010];

map<int, int> zip;
vector<pair<int, int> > member[200010];

int id[200010];

signed main(){
    cin >> w >> h >> n;
    vector<int> vec;

    {
        for(int i = 0;i < n;i++){
            cin >> x[i] >> y[i] >> d[i];
            vec.push_back(y[i]+x[i]);
        }

        sort(vec.begin(), vec.end());
        vec.erase(unique(vec.begin(), vec.end()), vec.end());

        for(int i = 0;i < vec.size();i++){
            zip[vec[i]] = i;
        }
    }

    for(int i = 0;i < n;i++){
        member[zip[y[i]+x[i]]].push_back(make_pair(x[i], i));
    }

    for(int i = 0;i < vec.size();i++){
        sort(member[i].begin(), member[i].end(), greater<pair<int, int> >());

        queue<int> que1;
        queue<int> que2;

        queue<int> ans;

        for(int j = 0;j < member[i].size();j++){
            int idx = member[i][j].second;
            if(d[idx] == 'S'){
                if(x[idx] % 2 == 0){
                    que1.push(idx);
                }else{
                    que2.push(idx);
                }
            }else{
                if((y[idx]+x[idx])%2 == 0){
                    if(x[idx]%2 == 0){
                        que1.push(idx);
                        ans.push(que1.front());
                        que1.pop();
                    }else{
                        que2.push(idx);
                        ans.push(que2.front());
                        que2.pop();
                    }
                }else{
                    if(x[idx]%2 == 1){
                        que1.push(idx);
                        ans.push(que1.front());
                        que1.pop();
                    }else{
                        que2.push(idx);
                        ans.push(que2.front());
                        que2.pop();
                    }
                }
            }
        }

        for(int j = 0;j < member[i].size();j++){
            int idx = member[i][j].second;
            if(d[idx] == 'S'){
                if(x[idx] % 2 == 0){
                    id[idx] = que1.front();
                    que1.pop();
                }else{
                    id[idx] = que2.front();
                    que2.pop();
                }
            }else{
                id[idx] = ans.front();
                ans.pop();
            }
        }
    }

    priority_queue<pair<int, int> > ans;

    for(int i = 0;i < n;i++){
        if(d[i] == 'S'){
            ans.push(make_pair(-(h-y[i]), -id[i]));
        }else{
            ans.push(make_pair(-(w-x[i]), -id[i]));
        }
    }

    while(!ans.empty()){
        cout << -ans.top().second+1 << endl;
        ans.pop();
    }

    return 0;
}

