#!/bin/python3 # forgets to actually move the game, should fail on sample # can't really think of any other WA to test has = {"fishing":"alice", "golf":"bob", "hockey":"charlie"} for _ in range(int(input())): a, _, _, _, g = input().split() if has[g] == a: print(a, "already has", g) else: print(a, "borrows", g, "from", has[g])