//Total number of turkeys is N
//Between 1 to 99
//Total price have 5 digits, only know the middle 3
//All turkeys same price, the price is integer
#include <stdio.h>
int main()
{
int n,x,y,z;
int a,b;
while(scanf("%d%d%d%d",&n,&x,&y,&z)!=EOF)
{
int findOrNot=0;
for(a=9;a>=1;a--)
{
for(b=9;b>=0;b--)
{
int temp=a*10000+x*1000+y*100+z*10+b;
if(temp%n==0)
{
findOrNot=1;
printf("%d %d %d\n",a,b,temp/n);
break;
}
}
if(findOrNot==1)
break;
}
if(findOrNot==0)
printf("0\n");
}
return 0;
}
//Total number of turkeys is N
//Between 1 to 99
//Total price have 5 digits, only know the middle 3
//All turkeys same price, the price is integer
#include <iostream>
using namespace std;
int main()
{
int n,x,y,z;
int a,b;
while(cin>>n>>x>>y>>z)
{
int findOrNot=0;
for(a=9;a>=1;a--)
{
for(b=9;b>=0;b--)
{
int temp=a*10000+x*1000+y*100+z*10+b;
if(temp%n==0)
{
findOrNot=1;
cout<<a<<" "<<b<<" "<<temp/n<<"\n";
break;
}
}
if(findOrNot==1)
break;
}
if(findOrNot==0)
cout<<0<<"\n";
}
return 0;
}