#include using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef vector vi; #define pb push_back #define mp make_pair #define MAXN 300'010 pii a[MAXN]; set xv[MAXN]; set yv[MAXN]; bool dead[MAXN]; int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); int n, m; cin >> n >> m; set xc; set yc; map xm; map ym; rep(i, 0, n) { cin >> a[i].first >> a[i].second; xc.insert(a[i].first); yc.insert(a[i].second); } for (int x : xc) { xm[x] = sz(xm); } for (int y : yc) { ym[y] = sz(ym); } rep(i, 0, n) { a[i].first = xm[a[i].first]; a[i].second = ym[a[i].second]; xv[a[i].first].insert(mp(a[i].second, i)); yv[a[i].second].insert(mp(a[i].first, i)); } vi out; while (m--) { int ind; cin >> ind; ind--; char c; cin >> c; if (dead[ind]) { cout << "ignore\n"; continue; } out.clear(); if (c == 'E') { // x go up auto iter = yv[a[ind].second].lower_bound(mp(a[ind].first, ind)); iter++; while (iter != end(yv[a[ind].second])) { out.pb(iter->second); iter++; } } else if (c == 'N') { // y go up auto iter = xv[a[ind].first].lower_bound(mp(a[ind].second, ind)); iter++; while (iter != end(xv[a[ind].first])) { out.pb(iter->second); iter++; } } else if (c == 'W') { // x go down auto iter = yv[a[ind].second].lower_bound(mp(a[ind].first, ind)); while (iter != begin(yv[a[ind].second])) { iter--; out.pb(iter->second); } } else { // y go down auto iter = xv[a[ind].first].lower_bound(mp(a[ind].second, ind)); while (iter != begin(xv[a[ind].first])) { iter--; out.pb(iter->second); } } cout << sz(out) << ' '; for (int x : out) { cout << x+1 << ' '; xv[a[x].first].erase(mp(a[x].second, x)); yv[a[x].second].erase(mp(a[x].first, x)); dead[x] = true; } cout << '\n'; } }