a,b,c,d,n;
main(z){
	for(;scanf("%d%d%d%d%d",&n,&a,&b,&c,&d),n/=10;d>0&&printf("500 %d\n",d))
		--z&&puts(""),n-=a+5*b+10*c+50*d,d+=n/50,c+=n%50/10,b+=n%10/5,a+=n%5,a&&printf("10 %d\n",a),b>0&&printf("50 %d\n",b),c>0&&printf("100 %d\n",c);
}