
// Arup Guha
// 7/23/07
// Alternate Solution to BHCSI Week #2 Contest Problem bicycle

import java.util.*;
import java.io.*;

public class bicycle2 {
	
	// Information for one racer
	private String name;
	private String color;
	private double speed;
	private double stamina;
	
	public bicycle2(String n, String c, double spd, double stam) {
		name = n;
		color = c;
		speed = spd;
		stamina = stam;
	}

	// Returns true iff the current object wins the race, then it updates
	// the stamina of the winner.	
	public boolean race(bicycle2 fred) {
		
		boolean returnValue;
		
		// Figure out who's going to win.
		if (1/(this.speed*this.stamina) < 1/(fred.speed*fred.stamina))
			returnValue = true;
		else if (1/(this.speed*this.stamina) > 1/(fred.speed*fred.stamina))
			returnValue = false;
		else {
			returnValue = ((this.name).compareTo(fred.name) < 0);
		}
		
		// Update stamina
		if (returnValue) {
			this.stamina = this.stamina/2;
		}
		else {
			fred.stamina = fred.stamina/2;
		}
		
		return returnValue;
	}
	
	// Returns a string version of the object that coincides with the
	// output of the problem.
	public String toString() {
		return name+" ("+ color + ") Stamina: "+stamina;
	}
	
	public static void main(String[] args) throws IOException {
		
		Scanner fin = new Scanner(new File("bicycle.in"));
	
		// Read in the number of races.	
		int numRaces = fin.nextInt();
		
		String name, color;
		double speed, stamina;
		
		// Set up the two bicycle racers objects.
		
		color = fin.next();
		name = fin.next();
		speed = fin.nextDouble();
		stamina = fin.nextDouble();
		bicycle2 racer1 = new bicycle2(name, color, speed, stamina);
		
		color = fin.next();
		name = fin.next();
		speed = fin.nextDouble();
		stamina = fin.nextDouble();
		bicycle2 racer2 = new bicycle2(name, color, speed, stamina);
		
		// Loop through all of the races.
		for (int i=1; i<=numRaces; i++) {
		
			boolean outcome = racer1.race(racer2);	
			
			// Output the header for this race.
			System.out.println("Race "+i+" Result");
			System.out.println("-------------");
			
			// Racer #1 Wins
			if (outcome) {
				System.out.println("1: "+racer1);
				System.out.println("2: "+racer2);
			}
			
			// Racer #2 Wins
			else {
				System.out.println("1: "+racer2);
				System.out.println("2: "+racer1);
			}
			System.out.println();
		}
		
		fin.close();
	}
}