#include<cstdio>
int main() {
    int n, x, y, z;
    scanf("%d\n %d %d %d", &n, &x, &y, &z);
    int a, b,price;
    int max=0,maxa,maxb;

    for (a = 1; a <= 9; ++a) {
        for (b = 0; b <= 9; ++b) {
            price=a * 10000 + x * 1000 + y * 100 + z * 10 + b;
            if(price % n == 0  && price>=(max*n)) {
                max=price/n;
                maxa=a;
                maxb=b;
            }
        }
    }
   if(max==0) {
       printf("%d",0);

       }
        else {
        printf("%d %d %d\n", maxa, maxb, max);
    }
    return 0;
}