import std.stdio, std.conv, std.string, std.bigint; import std.math, std.random, std.datetime; import std.array, std.range, std.algorithm, std.container; string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } class Facility{ string name; long benefit; long cost; long amount = 0; this(string na, long ben, long cost){ this.name = na; this.benefit = ben; this.cost = cost; } void buy(){ amount += 1; cost = (cost * 6 + 4) / 5; } } void main(){ int n = read.to!int; string s = readln.chomp; Facility click = new Facility("click", 1, 15); Facility[] facs = [ new Facility("hand", 1, 150), new Facility("lily", 10, 2_000), new Facility("factory", 120, 30_000), new Facility("casino", 2_000, 600_000), new Facility("grimoire", 25_000, 10_000_000) ]; long value = 0; foreach(i; n.iota){ string ans = "nothing"; real bestrate = 1.0; Facility bestfac = click; foreach(fa; facs){ if(fa.cost > value) continue; if(fa.benefit * (n - i) > fa.cost){ real rate = (fa.benefit * (n - i)).to!real / fa.cost.to!real; if(rate > bestrate) bestrate = rate, bestfac = fa; } } if(bestfac.name == "click"){ ans = "click"; value += 1; } else{ ans = "buy " ~ bestfac.name; value -= bestfac.cost; bestfac.buy; } foreach(fa; facs){ value += fa.benefit * fa.amount; } ans.writeln; stdout.flush; readln; } }