Colorgraph#8561

Colorgraph

1 second
128 megabytes
Hard

Lora is playing an online puzzle game. She receives an undirected graph with vertices, numbered from to . The graph is such that between every two distinct vertices there is an edge, colored either in blue, or in red. We will call the graph red-connected, if from any vertex we can reach any other vertex, using only red edges. Similarly, a graph is blue-connected if from any vertex we can reach any other vertex, using only blue edges. We now define the state of the graph as a pair of numbers , such that:

So for example, state describes a graph that is red-connected, but not blue-connected.

With a single click on a given edge, Lora can change its color (from blue to red or from red to blue). The goal of the game is, given an initial graph and a desired final state, to change the initial graph to one that is in the final state, using minimum amount of clicks (see the sample test cases for more information). Your task is to help Lora by writing a program colorgraph that finds the minimum amount of clicks needed to solve the problem.

Input

On the first line there is a positive integer (3 \le n \le 250) – the amount of vertices in the graph. After that lines follow, each with space-separated numbers, describing the colors of the edges. Let us denote the -th number on the -th of those lines by G_{ij}. If G_{ij} = 0, then the edge between and is red, and if G_{ij} = 1, then the edge between and is blue. It is guaranteed that G_{ij} = G_{ji}. For i = j the value of G_{ij} is irrelevant, since the graph contains no loops. On the last line are two space-separated numbers - and , describing the desired final state of the graph.

Output

If it is impossible to transform the graph into one with the desired state, you must print on a single line of the standard output.

In all other cases, on the first line of the standard output you must print a single integer - the minimum amount of clicks Lora needs to make in order to transform the graph into the desired state. On each of the next lines you must print a pair of numbers - the two endpoints of the edge that Lora should click on. If there is more than one solution, print any of them. The order, in which the edges are printed, as well as the order of the two endpoints, is irrelevant.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Example 3

Loading
Loading

Note

The red edges are given with solid lines, while the blue ones are given with dotted lines. In the first sample, we have the following initial graph in state :

prb8561.gif

After the change of edges - and -, the graph is in the desired final state and looks as follows:

prb8561_1.gif

In the second sample case, a graph with vertices and state does not exist.

In the third sample case, the graph is already in the desired final state initially.