#! /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} r = {'hand':1, 'lily':1, 'factory':1, 'casino':1, 'grimoire':1} for i in range(n): # print(c, d) f=0 cmd = '' if i == n - 1 and d['grimoire'] > 0: cmd = 'sell grimoire' for k in b: if c > b[k]*10 and a[k] * 5 < d[k] <= a[k] * 10 and r[k]: if b[k] >= 10000000 and i > n-400 : continue cmd += 'reinforce ' + k c -= b[k] a[k] *= 2 d[k] *= 2 r[k] = 0 break if cmd == '': for k in b: if c > b[k] and d[k] < a[k] * 10: if b[k] >= 10000000 and i > n-400 : continue 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()