i = false

while true
  cost = gets.to_i/10 ; break if cost==0

  puts "" if i
  i = true
  
  m1,m5,m10,m50 = gets.split(" ").map{|s| s.to_i}

  n = m1+5*m5+10*m10+50*m50

  for i in 0..m1
    for j in 0..m5
      for k in 0..m10
        for l in 0..m50
          change = (m1-i) + (m5-j)*5 + (m10-k)*10 + (m50-l*)50 - cost
          break if change >= 0
          nn = i+j+k+l + change%5+(change%10)/5+(change%50)/10+(change/50)
          a1,a5,a10,a50,n = m1-i,m5-j,m10-k,m50-l,nn if n>nn
        end
      end
    end
  end

  puts "10 #{a1}" if a1!=0
  puts "50 #{a5}" if a5!=0
  puts "100 #{a10}" if a10!=0
  puts "500 #{a50}" if a50!=0
end