Under construction

Still being built. Things may change

Nothing Everything

Time limit1sMemory limit1024 MB

Summary
Decide whether a graph can be built by adding each vertex either isolated or joined to all earlier vertices, and output the operations if it can.
Level

Medium5 of 10

Topics
Graph, Greedy, Implementation
Solved
No attempts yet

Problem

A undirected graph GG has NN vertices and MM edges. At the start, the graph contains only vertex 11. Determine whether GG can be built by performing the following two operations N−1N - 1 times, and if it can, print the sequence of operations in order.

  • If the ii-th operation is Nothing, add vertex i+1i+1 with no edges connecting it to any other vertex.
  • If the ii-th operation is Everything, add vertex i+1i+1 and connect it with an edge to every vertex from 11 to ii.

Input

The first line contains NN and MM, separated by a space.

Each of the next MM lines contains aia_i and bib_i, separated by a space. This means that graph GG has an edge between vertex aia_i and vertex bib_i. Graph GG has no duplicate edges.

Output

If GG can be built with the two operations, print on the first line a string of length N−1N - 1 consisting only of N and E. The jj-th character is N if the jj-th operation is Nothing, and E if it is Everything. If there are several valid sequences, print any one of them.

If GG cannot be built, print -1.

Constraints

  • 2≤N≤100 0002 \le N \le 100\,000
  • 0≤M≤min⁡(N(N−1)2,100 000)0 \le M \le \min \left( \frac{N(N-1)}{2}, 100\,000 \right)
  • 1≤ai,bi≤N1 \le a_i, b_i \le N
  • ai≠bia_i \ne b_i

Examples3

  1. Example 1

    Input
    2 0
    
    Expected output
    N
    
  2. Example 2

    Input
    3 3
    2 1
    3 2
    1 3
    
    Expected output
    EE
    
  3. Example 3

    Input
    4 2
    1 2
    3 4
    
    Expected output
    -1