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

1344. Gigantic Turnip

Time limit: 1.0 second
Memory limit: 64 MB
As usual old man has planted a turnip. Every year he plants a turnip and every year happens one and the same thing — the turnip grows gigantic. May be the old man has good artificial fertilizers, may be his surname is Michurin, may be the atomic station that is not far from that place tells on the yield. And this year the turnip has grown very big and the old man is to take it out.
The old man tried to call in an old wife aid but she suffers from sciatica since the previous year when they tried to take off a turnip. Granddaughter after that event received medical treatment in Switzerland (that turnip turned very expensive), and a dog, a cat and a mouse have got idiosyncrasy to root crops upon the whole.
The old man has grieved. Que faire? (What is to be done? — Fr) The turnip is to be taken off!
Suddenly the old man recalls that he’s got a precious book at the garret — a course of physics by Pyoryshkin for the secondary school. He remembered that very interesting things are described in this book – pulleys. The construction of such pulleys may help the old man to get along without the old wife, granddaughter, the dog, the cat and the mouse.
The old man takes the book, reads it, — and assembles a construction. Now he is sitting at the porch of his house and thinks how much will this construction help him to save on the force?
Pulley is a wheel with a rope thrown over it and another rope that is bound to the axle. If the rope that is bound to the axle looks up and the ends of the other rope that is thrown over the wheel look down then it is a pulley of the first type. If the rope that is bound to the axle looks down and the ends of the thrown over rope look up then it is a pulley of the second type.
Help the old man, given a configuration of blocks of the first and the second types, to determine the win in the force while the crop hasn’t rotted. Assume that two pulleys coupled with a rope are on different heights.


The first line contains integer N(1 ≤ N ≤ 32) — that is the number of pulleys. The pulleys are numbered with integers from 1 to N. The next N lines consist of the blocks description in the following format: T X1 X2 Y, where T — the pulley type (1 or 2), the ends of the rope thrown over the current pulley look towards the pulleys number X1 and X2, the rope that is bound to the axle looks towards the pulley number Y. However there are some exclusions.
  1. Some going up ropes are bound to the ceiling of the hothouse (the old man planted turnips in hothouses). In this case there is 0 instead of the number of pulley to which this ripe was to go.
  2. Exactly one rope that goes down from a pulley is bound to the turnip with mass 1 centner. In this case in the line with description of the i-th pulley number -1 instead of the pulley number is written.
  3. Exactly one rope going down from a pulley is free. Then there is -2 instead of the number of pulley in the description of the i-th pulley.
All the ropes are vertical.


You are to output the mass of a load in centners (within 4 digits after a decimal point) that is to be hung on the free rope in order to balance the system of pulleys. If there is no such a mass output “No solution”. If any mass suits output the string “Any”.


1 -1 2 0
2 1 0 -2
1 3 2 0
2 1 0 4
1 -1 4 1
2 3 2 -2
No solution
1 2 2 0
2 1 1 -2
1 4 4 0
2 3 3 -1
Problem Author: Pavel Egorov
Problem Source: USU Championship 2004