/*
AizuOnline A2007
Purse
2012/12/31 WA
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
#define min(x,y) (((x)<(y))?(x):(y))
//Global data section
int c10,c50,c100,c500;
int m10,m50,m100,m500;
int sum;
//
int _read()
{
  // sum=160;
  // c10=1;c50=1;c100=2;c500=0;
  scanf("%d",&sum);
  if(sum ==0)
    return(0);
  scanf("%d %d %d %d",&c10,&c50,&c100,&c500);
  return(-1);
}
main()
{ 
  int flag=0,wk;
  while(_read())
    {
      if(flag)
	printf("\n");
      flag=-1;
      m10 =  (sum % 50)/10 ;
      if(m10 > c10)
	{
	  m10=0;
	  sum += 50 - (sum % 50);
	}
      else
	{	  
	  m10 += ((c10 - m10)/ 5)* 5;
	  sum -= m10*10;
	}
      //if(sum < 0)sum=0;
      m50 =  (sum % 100)/50;
      //printf("m50A:%d\n",m50);
      if(m50 > c50)
	{
	  m50=0;
	  sum += 100 - (sum % 100);
	}
      else
	{
	  m50 += ((c50 - m50) / 2)*2;
	  sum -= m50*50;
	}
      //if(sum < 0)sum=0;
      m100 = (sum % 500)/100;
      // printf("m100:%d\n",m100);
      if(m100 > c100)
	{
	  m100=0;
	  sum += 500 - (sum % 500);
	}
      else
	{
	  m100 += ((c100 - m100)/5)*5;
	  sum -= m100*100;
	  if(sum < 0)
	    sum = 0;
	}
      m500 = sum / 500;
      
      if(m10 > 0)
	printf("10 %d\n",m10);
      if(m50 > 0)
	printf("50 %d\n",m50);
      if(m100 > 0)
	printf("100 %d\n",m100);
      if(m500 > 0)
	printf("500 %d\n",m500);
    }

return(0);
}