atcoder#ARC111D. [ARC111D] Orientation

[ARC111D] Orientation

Score : 600600 points

Problem Statement

Given is a simple undirected graph with NN vertices and MM edges. The vertices are numbered 1,,N1, \cdots, N, and the ii-th edge connects Vertices aia_i and bib_i. Also given is a sequence of positive integers: c1,c2,,cNc_1, c_2, \cdots, c_N.

Convert this graph into a directed graph that satisfies the condition below, that is, for each ii, delete the undirected edge (ai,bi)(a_i, b_i) and add one of the two direted edges aibia_i \to b_i and biaib_i \to a_i.

  • For every i=1,2,,Ni = 1, 2, \cdots, N, there are exactly cic_i vertices reachable from Vertex ii (by traversing some number of directed edges), including Vertex ii itself.

In this problem, it is guaranteed that the given input always has a solution.

Constraints

  • 1N1001 \leq N \leq 100
  • 0MN(N1)20 \leq M \leq \frac{N(N - 1)}{2}
  • 1ai,biN1 \leq a_i, b_i \leq N
  • The given graph has no self-loops and no multi-edges.
  • 1ciN1 \leq c_i \leq N
  • There always exists a valid solution.

Input

Input is given from Standard Input in the following format:

NN MM

a1a_1 b1b_1

::

aMa_M bMb_M

c1c_1 c2c_2 ...... cNc_N

Output

Print MM lines.

To add the edge aibia_i \to b_i for the ii-th edge, print -> in the ii-th line; to add the edge biaib_i \to a_i for the ii-th edge, print <-.

If there are multiple solutions, any of them will be accepted.

3 3
1 2
2 3
3 1
3 3 3
->
->
->

In a cycle of length 33, you can reach every vertex from any vertex.

3 2
1 2
2 3
1 2 3
<-
<-
6 3
1 2
4 3
5 6
1 2 1 2 2 1
<-
->
->

The graph may be disconnected.