CCCPaste

Untitled

#include 
//#include 
#include 
#include 
using namespace std;


int main()
{
    int n;
    cin >> n;
    
    vector > v;
    
    for(int i = 0; i < n; i++) {
        int x;
        cin >> x;
        string s;
        cin >> s;
        v.push_back(make_pair(x, s));
    }
    sort(v.begin(), v.end());
    int posledno_ne = 0, prvo_da = -1;
    for(int i = 0; i < v.size(); i++) {
        if(v[i].second == "NE") {
            posledno_ne = v[i].first;
        }
        else {
            prvo_da = v[i].first;
            break;
        }
    }
    cout << posledno_ne + 1 << " " << prvo_da - 1 << endl;
    return 0;
}