Under construction

Still being built. Things may change

Bracket Euler Tour

Time limit2sMemory limit512 MB

Summary
Find an Euler tour of an undirected graph whose vertex bracket labels, read in traversal order, form a correct bracket sequence, or report that none exists.
Level

Hard9 of 10

Topics
Graph, DFS, Greedy, Implementation
Solved
No attempts yet

Problem

You are given an undirected graph with nn vertices and mm edges. Each vertex has a bracket (either opening “(” or closing “)”) associated with it.

You have to find an Euler tour in this graph such that its vertices (written in traversal order) form a correct bracket sequence.

A correct bracket sequence is a sequence of brackets that can be transformed into a correct arithmetic expression by inserting characters “1” and “+” between the original characters of the sequence. For example, bracket sequences “()()” and “(())” are correct (the resulting expressions are “(1)+(1)” and “((1+1)+1)”). In contrast, “)(” and “()(” are not.

An Euler tour of an undirected graph is a cycle which visits every edge in the graph exactly once. Visiting the same vertex multiple times is allowed.

Input

The first line contains two integers nn and mm (1≤n,m≤2⋅1051 \le n, m \le 2 \cdot 10^5), the number of vertices and edges respectively.

Each of the following mm lines contains two integers viv_i and uiu_i (1≤vi,ui≤n1 \le v_i, u_i \le n), meaning that there is an undirected edge between vertices viv_i and uiu_i. Self-loops and multiple edges are allowed.

The last line of the input contains a string of nn round brackets, where the ii-th bracket is associated with vertex ii.

Output

If there is no Euler tour in the given graph that forms a correct bracket sequence, print “No” in the first line.

Otherwise, print “Yes” in the first line. In the second line, print a sequence of vertices that forms an Euler tour and also a correct bracket sequence. If there are multiple solutions, print any of them.

Examples3

  1. Example 1

    Input
    2 2
    1 2
    1 2
    )(
    
    Expected output
    Yes
    2 1
    
  2. Example 2

    Input
    5 6
    1 2
    2 3
    3 1
    2 4
    4 5
    5 2
    (()))
    
    Expected output
    Yes
    1 2 4 5 2 3
    
  3. Example 3

    Input
    1 1
    1 1
    (
    
    Expected output
    No