All submissions for this problem are available.### Read problem statements in [Hindi](http://www.codechef.com/download/translated/MARCH20/hindi/EGGFREE.pdf), [Bengali](http://www.codechef.com/download/translated/MARCH20/bengali/EGGFREE.pdf), [Mandarin Chinese](http://www.codechef.com/download/translated/MARCH20/mandarin/EGGFREE.pdf), [Russian](http://www.codechef.com/download/translated/MARCH20/russian/EGGFREE.pdf), and [Vietnamese](http://www.codechef.com/download/translated/MARCH20/vietnamese/EGGFREE.pdf) as well. Let's call a directed graph *egg-free* if it is acyclic and for any three pairwise distinct vertices $x$, $y$ and $z$, if the graph contains edges $x \rightarrow y$ and $x \rightarrow z$, then it also contains an edge $y \rightarrow z$ and/or an edge $z \rightarrow y$. You are given an undirected graph with $N$ vertices (numbered $1$ through $N$) and $M$ edges (numbered $1$ through $M$). Find a way to assign a direction to each of its edges such that the resulting directed graph is egg-free, or determine that it is impossible. If there are multiple solutions, you may find any one. ### Input - The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. - The first line of each test case contains two space-separated integers $N$ and $M$. - $M$ lines follow. For each valid $i$, the $i$-th of these lines contains two space-separated integers $u_i$ and $v_i$ denoting an edge between vertices $u_i$ and $v_i$. ### Output For each test case: - If it is impossible to assign a direction to each edge in such a way that the resulting graph is egg-free, print a single line containing the string `"No solution"` (without quotes). - Otherwise, print a single line containing a string with length $M$. For each valid $i$, the $i$-th character of this string should be '^' if you want to direct the $i$-th edge from $u_i$ to $v_i$, or 'v' if you want to direct it from $v_i$ to $u_i$. ### Constraints - $1 \le T \le 5$ - $1 \le N, M \le 200,000$ - $1 \le u_i, v_i \le N$ for each valid $i$ - $u_i \neq v_i$ for each valid $i$ - each pair of vertices is connected by at most one edge ### Subtasks **Subtask #1 (10 points):** $N, M \le 20$ **Subtask #2 (20 points):** $N, M \le 200$ **Subtask #3 (70 points):** original constraints ### Example Input ``` 2 3 3 1 2 2 3 3 1 7 6 1 2 2 3 3 4 4 5 5 6 6 7 ``` ### Example Output ``` ^^v ^^^^^^ ```
|Tags||chordal-graph, gainullinildar, hard, march20, tmwilliamlin|
|Time Limit:||3 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, CPP17, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.