Problems
We want to place a circuit on an
Here, each grid (square cell) has four neighboring grids (up, down, left, and right), except for the grids on the edges.
A circuit is a path of consecutive neighboring grids with a start and an end.
In the figure below, there are two circuits connecting
Given the two end grids of a new circuit to be placed on a grid board where circuits are already placed,
we want to place a new circuit connecting these two grids.
The new circuit to be placed may be placed on top of grids where circuits are already placed.
The placement cost of this circuit is determined as follows, depending on the grids the circuit passes through.
The cost of passing through an empty grid where no circuit is placed is 1,
and the cost of passing through a grid where a circuit is already placed is k(k≥2).
The given problem is to find a new circuit that incurs the minimum cost.
For example, if k is given as 4 in the figure below,
the cost of the circuit connecting grids
(This cost also includes the costs of

Input
The first line of the input contains an integer
The second line contains
The third line contains an integer
The fourth line contains the number of already placed circuits.
From the fifth line onwards, the placement information for one circuit per line is given as follows.
The first integer is the total number of the circuit's starting grid, the grids where it turns 90°, and the ending grid,
and from then on, the positions of these grids are given in the order of row and column from the starting grid to the ending grid.
Output
On the first line, output the minimum cost of the circuit.
On the second line, output the information of the minimum cost circuit as follows.
(Same as the input format) First, output the total number of the starting grid, the grids where the direction changes by 90°, and the last grid.
Then, output the positions of these grids from the starting grid to the last grid, one by one in the order of row and column, separated by a space.
Example
11
2 3 9 8
4
2
3 3 9 3 4 10 4
4 9 2 7 2 7 7 5 7
16
3 2 3 2 8 9 8