include<stdio.h>

main()
{
int n,x,y,z,a,b,c,k=0,d,e;
scanf("%d\n %d %d %d",&n,&x,&y,&z);
for(a=1;a<10;a++)
{
for(b=0;b<10;b++)
{
if((a10000+x1000+y100+z10+b)%n==0)
{
c=(a10000+x1000+y100+z10+b)/n;
if(k<c)
{
k=c;
d=a;
e=b;
}

        }
    }
}
if(k==0)
{
    printf("%d",0);
}
else
{
    printf("%d %d %d",d,e,k);
}
return(0);

}