#include <iostream> using namespace std; int main() { int chickenNum; while(cin>>chickenNum){ int a,b,c; cin>>a>>b>>c; int midNum = c*10+b*100+a*1000; bool isFind=0; for(int i =9;i>=1;i--){ for(int j = 9;j>=0;j--){ int temp = (midNum+i*10000+j); if(temp%chickenNum==0){ cout<<i<<" "<<j<<" "<<temp/chickenNum<<endl; isFind=1; break; } } if(isFind)break; } if(!isFind)cout<<0<<endl; } } // 64 位输出请用 printf("%lld")