#! /usr/bin/env python3 n = int(input()) s = input() c = 0 a = {'hand':1, 'lily':10, 'factory':120, 'casino':2000, 'grimoire':25000} b = {'hand':150, 'lily':2000, 'factory':30000, 'casino':600000, 'grimoire':10000000} d = {'hand':1, 'lily':0, 'factory':0, 'casino':0, 'grimoire':0} for i in range(n): # print(c, d) f=0 cmd = '' for k in b: if c > b[k] and d[k] < a[k] * 10: cmd += 'buy ' + k c -= b[k] b[k] = int(1.2 * b[k]) d[k] += a[k] break if cmd == '' : cmd = 'click' f=1 print(cmd) for i, j in d.items(): if i == 'hand' and f: c += j else: c += j s = input()