require 'stringio'

uyile=->{
  a = Hash.new
  ->n{
  if a[n.to_s].nil?
    a[n.to_s] = StringIO.new <<
    if n.is_a? Fixnum
      n.times
    else
      n.map
    end.to_a.join("\n")
    a[n.to_s].rewind
  end
  a[n.to_s].gets
}}.call
# print "test "+$_ while uyile.yield 3
print "test "+$_ while uyile.yield 4
print "test "+$_ while uyile.yield "a".."f"
print "test "+$_ while uyile.yield 4.times