// 九度:1036
//
//
//
#include <stdio.h>
int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("E:\\in.txt", "r", stdin);
// freopen("E:\\out.txt", "w", stdout);
#endif
int n;
while(scanf("%d", &n) != EOF)
{
int x , y, z;
scanf("%d%d%d", &x, &y, &z);
int t = x*1000 + y*100 + z*10;
int max=0, t1, t2;
for(int i=1; i<=9; i++)
{
for(int j=0; j<=9; j++)
{
int totalprice = i*10000 + t + j;
if(totalprice%n == 0)
{
int per = totalprice/n;
if(per > max)
{
max=per;
t1 = i;
t2 = j;
}
}
}
}
if(max != 0)
{
printf("%d %d %d\n", t1, t2, max);
}
else
{
printf("0\n");
}
}//while
return 0;
}