import java.util.*; 
import java.util.*; 

public class arbitrage {
	
	static double[][] rates;
	static boolean[][] was;
	static int c;
	static int start;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		c = -1;
		while (c != 0) {
			c = sc.nextInt();
			
			if (c == 0) {
				break;
			}
			
			HashMap<String, Integer> names = new HashMap<String, Integer>();
			
			sc.nextLine();
			String[] toks = sc.nextLine().split(" ");
	
			for (int i = 0; i < c; i++) {
				names.put(toks[i], i);
			}
			
			int r = sc.nextInt();sc.nextLine();
			rates = new double[c][c];
			
			for (int i = 0; i < r; i++) {
				String line = sc.nextLine();
				
				toks = line.split(" ");
								
				int a = names.get(toks[0]);
				int b = names.get(toks[1]);
				
				toks = toks[2].split(":");
				
				int[] newr = new int[2];
				
				newr[0] = Integer.parseInt(toks[0]);
				newr[1] = Integer.parseInt(toks[1]);
				
				rates[a][b] = newr[0] / (double) newr[1];
				
				
			}
			
			// dfs
			
			boolean arb = false;
			for (int i = 0; i < c; i++) {
				was = new boolean[c][c];
				//was[i] = true;
				start = i;
				double res = dfs(i, 1);
				if (res < 1) {
					System.out.println("Arbitrage");
					arb = true;
					break;
				}
			}
			
			if (!arb) {
				System.out.println("Ok");
			}
		}
	}
	
	public static double dfs(int from, double diff) 
	{		
		for (int i = 0; i < c; i++) 
		{
			if (was[from][i]) {
				continue;
			}
			
			if (rates[from][i] == 0) {
				continue;
			}
			
			//System.out.println(from + " " + c);
			
			was[from][i] = true;
			double newDiff = 0;
			
			newDiff = diff * rates[from][i];
			
			
			
			//System.out.println(from + " > " + i + " = " + Arrays.toString(newDiff));
			
			if (i == start) {
				return newDiff;
			}
			
			double res = dfs(i, newDiff);
			was[from][i] = false;
			
			if (res < 1) {
				return res;
			}
		}
		
		//if (from != start) {
		return 1;
		//}
		
		//return diff;
	}
}