#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
int N,a,b,c,d;
bool f=false;
while(1){
cin>>N;if(N==0)break;
if(f==true)cout<<endl;
f=true;
cin>>a>>b>>c>>d;

int min=a+b+c+d;
int y=0;
int s=0,t=0,u=0,v=0;
int sum=0;
sum+=10*a;
sum+=50*b;
sum+=100*c;
sum+=500*d;
sum=sum-N;


v=sum/500;sum=sum%500;
u=sum/100;sum=sum%100;
t=sum/50;sum=sum%50;
s=sum/10;sum=sum%10;


if(a-s>0)cout<<"10 "<<a-s<<endl;
if(b-t>0)cout<<"50 "<<b-t<<endl;
if(c-u>0)cout<<"100 "<<c-u<<endl;
if(d-v>0)cout<<"500 "<<d-v<<endl;

}

return 0;
}