题目描述
Problem Description
Snuke has a directed graph with $N$ vertices numbered from $1$ to $N$. Initially, this graph has no edges. Snuke's task is to add $M$ edges to this graph so that for any pair of vertices $(u, v)$, it is possible to reach $v$ from $u$ by following the edges.
Edges are added using two sequences $a$ and $b$ of length $M$. Snuke can freely rearrange the elements of $a$ and $b$ (but cannot swap elements between $a$ and $b$), and then use these sequences to add $M$ directed edges to the graph.
For the $i$-th edge, Snuke can add either of the following edges:
- A directed edge from vertex $a_i$ to $b_i$
- A directed edge from vertex $b_i$ to $a_i$
Is it possible for Snuke to complete his task? If possible, show an example of how to add the edges.
Input Format
The input is given from the standard input in the following format:
$N$ $M$ $a_1$ $a_2$ $...$ $a_{M}$ $b_1$ $b_2$ $...$ $b_{M}$
Output Format
If Snuke's task is achievable, output Yes. Otherwise, output No. If achievable, output $M$ lines in the following format to show how to add the edges:
$x_1$ $c_1$ $y_1$ $ : $ $x_{M}$ $c_{M}$ $y_{M}$
Here, $c_i$ being > indicates a directed edge from $x_i$ to $y_i$, and $c_i$ being < indicates a directed edge from $y_i$ to $x_i$. $x$ and $y$ are the rearranged sequences of $a$ and $b$, respectively, and the solution is correct if for any pair of vertices $u, v$, it is possible to reach $v$ from $u$ by following the edges.
Sample Input and Output
Sample Input #1
3 6
1 2 3 1 1 1
3 2 1 1 1 2
Sample Output #1
Yes
1 > 2
1 < 2
1 > 3
3 > 1
1 < 1
2 > 1
Sample Input #2
3 1
1
2
Sample Output #2
No
Sample Input #3
13 29
2 8 4 5 5 8 2 9 2 5 9 4 3 8 4 2 12 4 4 12 8 8 3 12 3 9 4 8 9
6 1 1 11 12 6 9 12 6 13 10 11 13 6 10 10 11 3 10 13 10 13 7 7 11 7 11 10 12
Sample Output #3
Yes
2 > 6
12 < 1
5 > 1
4 > 11
2 < 12
12 < 6
4 < 9
3 > 12
8 < 6
9 > 13
4 < 10
3 < 11
4 < 13
2 < 6
8 > 10
5 > 10
4 < 11
12 < 3
8 < 10
9 < 13
4 > 10
9 < 13
8 > 7
8 < 7
5 < 11
2 < 7
9 < 11
8 < 10
3 > 12
Notes/Hints
Constraints
- $1 \leq N, M \leq 2 \times 10^5$
- $1 \leq a_i, b_i \leq N$
- All given inputs are integers
Sample Explanation 1
- By constructing a graph as shown in the figure below, Snuke can achieve his task. Note that the final graph may include multiple edges or self-loops.

Sample Explanation 2
- No matter how edges are added, Snuke cannot achieve his task.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分