Grammy Sorting

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

Grammy has a connected undirected graph GG with nn vertices numbered 1,2,,n1, 2, \ldots, n. Among them are two special vertices AA and BB. Each vertex ii has a number p_ip\_i written on it, where p_1,p_2,,p_np\_1, p\_2, \ldots, p\_n is a permutation of 1,2,,n1, 2, \ldots, n.

Grammy thinks these numbers on vertices are too chaotic. She wants to reorder the numbers such that, for each vertex xx, there exists a path satisfying the following conditions:

  • The path starts from AA and ends at BB.
  • The path contains vertex xx.
  • The numbers along the path are strictly increasing.

Sadly, in each operation, Grammy can only choose a simple path starting from AA and ending at an arbitrary vertex, then shift the numbers on the simple path one position nearer to the start, and put the first number to the last position. Formally, if the vertices on the simple path chosen by Grammy contain numbers a_1,a_2,,a_k1,a_ka\_1, a\_2, \ldots, a\_{k-1}, a\_k, from start to end, then after Grammy's operation, these vertices will contain a_2,a_3,,a_k,a_1a\_2, a\_3, \ldots, a\_k, a\_1.

Additionally, Grammy can only operate no more than 10,00010\\,000 times.

Grammy is out of ideas on how to solve this problem, so she asked you for help.

Please help Grammy to determine whether she can reorder the numbers as required. You also need to output a solution if it exists.

입력

The first line contains four integers nn, mm, AA, BB (2n10002 \leq n \leq 1000, 1m20001 \leq m \leq 2000, 1A,Bn1 \leq A, B \leq n, ABA \neq B).

The second line contains nn integers p_1,p_2,,p_np\_1, p\_2, \ldots, p\_n (1p_in1 \leq p\_i \leq n). It is guaranteed that p_1,p_2,,p_np\_1, p\_2, \ldots, p\_n is a permutation.

In each of the next mm lines, there are two integers u_iu\_i and v_iv\_i (1u_i,v_in1 \leq u\_i, v\_i \leq n, u_iv_iu\_i \ne v\_i), denoting that there is a bidirectional edge between u_iu\_i and v_iv\_i. It is guaranteed that the graph is connected and that there is at most one edge between any two pair of vertices.

출력

If Grammy cannot properly reorder the numbers, output "-1" (without quotes).

Otherwise output an integer op\mathit{op} (0op10,0000 \leq \mathit{op} \leq 10\\,000) on the first line, indicating the number of operations to perform.

On each of the following op\mathit{op} lines, first output an integer kk denoting the number of vertices on the chosen simple path. Then output kk integers x_1,x_2,,x_kx\_1, x\_2, \ldots, x\_k (x_1=Ax\_1 = A, 1x_in1 \leq x\_i \leq n), indicating the vertices on the simple path. These x_ix\_i should be distinct and form a path in GG.

It can be shown that, if graph GG can be properly reordered, there exists a solution with no more than 10,00010\\,000 operations.

Note that you don't have to minimize op\mathit{op}. If there are multiple solutions, output any one of them.