Operations on graph#2472

Operations on graph

3 seconds
128 megabytes
Very easy

Create an undirected graph that supports the following operations:

  1. AddEdge(u, v) — add an edge between vertices (u, v) in the graph;

  2. Vertex(u) — print the list of vertices adjacent to vertex u.

There are no loops or multiple edges in the graph.

Input

The first line contains the number of vertices (1 \le n \le 10^5). The next line contains the number of operations (0 \le k \le 10^6). Each of the next lines describes an operation in the format: "1 <number> <number>" or "2 <number>", representing, respectively, the operations AddEdge(u, v) and Vertex(u).

It is guaranteed that the total number of numbers printed during all Vertex operations does not exceed 2 \cdot 10^5.

Output

For each Vertex command, print in a separate line the list of adjacent vertices for the given vertex. The vertices in each list can be printed in any order. If the given vertex has no adjacent vertices, print an empty line.

prb2472.gif

Examples

Example 1

Loading
Loading