1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
using namespace std;

int main() {
    int n, finals, total = 0;
    string s;
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> s >> finals;
        if(s[0] == 'N') continue;
        if(total >= 10 && finals >= 2) continue;
        if(total) cout << " ";
        cout << i;
        if(++total == 20) {
            cout << endl;
            break;
        }
    }
    return 0;
}