Tommy is a wheel thief. His job used to be simple: lift a car, unscrew the wheel bolts, take the wheel, and run. But nowadays everyone uses "anti-theft" bolts.
An anti-theft bolt is designed so that it cannot be loosened with an ordinary wrench. Its head is a cylinder with a hole, and to loosen it you need a dedicated wrench: a ring with a lug shaped to fit exactly into the hole of the bolt head.

Tommy cannot carry a wrench for every possible anti-theft bolt. Fortunately, a bolt can sometimes be loosened with a wrench that does not match it exactly.
Formally, a wrench can loosen a bolt if and only if both of the following hold:

Both shapes -- the hole of the bolt head and the lug of the wrench -- are star-shaped polygons whose center coincides with the center of the bolt (or of the wrench). Written in polar coordinates as a sequence of pairs $(r_i, \varphi_i)$, they satisfy $\varphi_i < \varphi_{i+1}$ and $\varphi_{i+1} - \varphi_i < 180^\circ$, so the center always lies strictly inside.

Determine which of Tommy's wrenches can loosen the bolt.
The first line contains two integers $n$ and $R$ -- the number of wrenches and the radius of the bolt head and of the wrenches' rings ($1 \le n \le 10$, $1 \le R \le 1000$).
Next comes the description of the bolt head: an integer $m$ -- the number of vertices ($3 \le m \le 100$) -- followed by $m$ integer pairs $(r_i, \varphi_i)$ ($1 \le r_i < R$; $0^\circ \le \varphi_i < 360^\circ$; $\varphi_i < \varphi_{i+1}$; $\varphi_{i+1} - \varphi_i < 180^\circ$; $\varphi_m - \varphi_1 > 180^\circ$).
The remaining lines describe the $n$ wrenches in the same format.
On the first line, print the number of wrenches that can loosen the bolt. On the second line, print their indices (starting from 1) in increasing order, separated by single spaces. If no wrench works, print only the first line (the number 0).