Buy souvenirs from merchants in order using gold coins (worth g silver) and silver coins. Merchants round change in silver packages as greedy, honest, or generous. Generous merchants require exact silver payment when possible; otherwise pay one gold coin. Other merchants accept exact silver or one gold coin. Maximize purchases.
g, c, n, then n lines with merchant type, package size pi, and price si.
Maximum number of souvenirs you can buy.