#include #include #include #include #include #define FOR(a,b,c) for(int a=b;a<=c;a++) #define REP(a,c) for(int a=0;a=c;a--) #define WT while(1) #define GETI(a) scanf("%d", &a) #define BZ(a) memset(a,0,sizeof(a)) #define FILL(a,b) fill(a,a+(sizeof(a)/sizeof(a[0])),b) #define FOREACH(a,b) for(__typeof((b).begin()) a=(b).begin(); a!=(b).end();a++) #define D(args...) //printf(args) using namespace std; #include #include int X[1010], Y[1010]; map > rows, cols; struct crows { bool operator()(int a, int b) { return X[a] < X[b]; } } CROWS; struct ccols { bool operator()(int a, int b) { return Y[a] < Y[b]; } } CCOLS; int xlink[1010], ylink[1010]; int main() { WT { int N; GETI(N); if(!N) break; REP(i, N) { GETI(X[i]); GETI(Y[i]); rows[Y[i]].push_back(i); cols[X[i]].push_back(i); xlink[i]=-1; ylink[i]=-1; } FOREACH(r, rows) { sort(r->second.begin(), r->second.end(), CROWS); int n = r->second.size(); int *ptr = &r->second[0]; REP(i, n/2) { ylink[ptr[0]] = ptr[1]; ylink[ptr[1]] = ptr[0]; D("Y %d %d\n", ptr[0], ptr[1]); ptr+=2; } } FOREACH(c, cols) { sort(c->second.begin(), c->second.end(), CCOLS); int n = c->second.size(); int *ptr = &c->second[0]; REP(i, n/2) { xlink[ptr[0]] = ptr[1]; xlink[ptr[1]] = ptr[0]; D("X %d %d\n", ptr[0], ptr[1]); ptr+=2; } } int idx=0; bool gox=true; long area=0; WT { D("idx %d\n", idx); int next; if(gox) next = xlink[idx]; else next = ylink[idx]; gox=!gox; int dx = X[next]-X[idx]; int dy = Y[next]-Y[idx]; area += dx*Y[idx] - dy*X[idx]; if(next == 0) break; else idx = next; } if(area > 0) gox=true; else gox=false; idx=0; WT { D("idx2 %d\n", idx); int next; if(gox) { next = xlink[idx]; if(Y[next] > Y[idx]) printf("N"); else printf("S"); } else { next = ylink[idx]; if(X[next] > X[idx]) printf("E"); else printf("W"); } gox=!gox; if(next == 0) break; else idx = next; } printf("\n"); rows.clear(); cols.clear(); } return 0; }