ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1291. Gear-wheels

Time limit: 1.0 second
Memory limit: 64 MB
— Arny! What happened with coordinator?
Bad working coordinator was the everlasting trouble of their spaceship. Arny already had been working under this trouble while his not very attentive and responsible mate just noticed the breakage. Judging by schematics the broken module of coordinator consists of the set of special gears connected with each other in order to transfer the traction from the kinetic generator to the lot of antenna driving engines.
Despite the extraterrestrial origin of these gears, they are connected by usual terrestrial method: the cogs of one gear-wheel get into the slots between cogs of another gear-wheel. So the rotation of the first gear-wheel is transmitted to the second gear-wheel.
After the multiple Arny’s revisions, no unnecessary gears stayed in the coordinator. It means that there is no cycles in gears connection graph. The only problem now is to check that all the gears have right directions and speeds of rotation.

Input

First line of input contains the number of gear-wheels in mechanism N (1 ≤ N ≤ 1000). The next N lines contain the information about the gear-wheels. i-th line contains K (1 ≤ K ≤ 1000) — the number of cogs on the i-th gear-wheel followed by the list of gears, that are connected to the i-th one. Zero ends the list.
The last line of input contains the number of gear-wheel, that is connected to the kinetic-generator and the speed of its rotation V (1 ≤ V ≤ 1000). This gear-wheel rotates in counter-clockwise direction.

Output

Output should contain N lines. In the i-th line there is a speed of rotation of i-th gear-wheel in the form of irreducible fraction. Numerator and denominator of this fraction should be separated by the sign ‘/’. If speed is negative, it is assumed that the gear-wheel rotates in clockwise direction (in this case the minus sign should be displayed before numerator). Otherwise the gear-wheel rotates in counter-clockwise direction. If speed equals zero than numerator should be equal 0 and denominator should be equal to 1. It is guaranteed that neither numerator nor denominator of all speeds will be greater than 106.

Sample

inputoutput
4
10 2 3 0
20 1 0
40 1 4 0
100 3 0
1 6
6/1
-3/1
-3/2
3/5
Problem Author: Pavel Egorov
Problem Source: IX Open Collegiate Programming Contest of the High School Pupils (13.03.2004)