#include "stdio.h"

int main(){ int x;//bill的千位 int y;//bill的百位 int z;//bill的十位 int n;//鸡的个数 int pay;

while(scanf("%d %d %d %d",&n,&x,&y,&z)!=EOF){
    int  max=0,pay=0,i1,j2;
    for (int i =1 ; i < 10; i++) {
   for (int j = 0; j <=9 ; j++) {

       pay= i*10000+x*1000+y*100+z*10+j;
       if (pay%n==0)
           if(max<(pay/n)){
               max=pay/n;
               i1=i;
               j2=j;
           }
               
   }

} if(max==0) printf("%d",max); else printf("%d %d %d\n",i1,j2,max);

}

}