// testing deleting from a vector (should TLE) #include using namespace std; using pii = pair; int main() { int N, M; cin >> N >> M; unordered_map> ver, hor; vector loc(N+1); vector rem(N+1, true); for (int i = 1; i <= N; ++i) { int x, y; cin >> x >> y; loc[i] = {x,y}; ver[x].push_back({y,i}); hor[y].push_back({x,i}); } for (auto& [x,s] : ver) sort(s.begin(), s.end()); for (auto& [y,s] : hor) sort(s.begin(), s.end()); for (int j = 0; j < M; ++j) { int i; char d; cin >> i >> d; auto [x,y] = loc[i]; if (!rem[i]) cout << "ignore" << endl; else { vector elim; if (d == 'N') { auto endi = ver[x].end(); auto start = prev(endi); while (start->second != i) --start; elim = vector(++start, endi); ver[x].erase(start, endi); } if (d == 'S') { auto start = ver[x].begin(); auto endi = start; while (endi->second != i) ++endi; elim = vector(start, endi); ver[x].erase(start, endi); reverse(elim.begin(), elim.end()); } if (d == 'E') { auto endi = hor[y].end(); auto start = prev(endi); while (start->second != i) --start; elim = vector(++start, endi); hor[y].erase(start, endi); } if (d == 'W') { auto start = hor[y].begin(); auto endi = start; while (endi->second != i) ++endi; elim = vector(start, endi); hor[y].erase(start, endi); reverse(elim.begin(), elim.end()); } vector fnl; for (auto [_,i] : elim) { if (rem[i]) { fnl.push_back(i); rem[i] = false; } } cout << fnl.size(); for (int i : fnl) cout << ' ' << i; cout << endl; } } }