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 = i + j*5 + k*10 + l*50 - cost
          if change >= 0
            mm1 = m1-i+change%5
            mm5 = m5-j+(change%10)/5
            mm10 = m10-k+(change%50)/10
            mm50 = m50-l+(change/50)

            nn = mm1+mm5+mm10+mm50
            a1,a5,a10,a50,n = i,j,k,l,nn if n>nn

          end
        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