题目描述
Zhejiang Sci-tech university has many gates, and many roads. Now you are in the dorm, and should go to No. 3 building to study. You can select either gate to enter into the campus. and you can select either road joint to the gate to reach the reach the library( the library has many point,for example the square, the back door and others you can reach), then you can select either road to the No.3 building.
输入
The input begins with a positive number N ( 2 <= N <= 5 ) on a line of its own telling the number of gates.
Then one line contains N integer number denote the time you go from your dorm to each gate of the university.
Then N lines, each line contains one number m ( 2 <= m <= 5 , the number of the points of library the gate can reach ) some pairs of number. Each pair
Then