#include<iostream>
using namespace std;

void process(int n, int x, int y, int z) {
    int maxValue = 0;
    int left=1, right=0;
    for(int a=1; a<10; a++) {
        for(int b=0; b<10; b++) {
            int total = a*10000+x*1000+y*100+z*10+b;
            int temp = total/n;
            if(total%n == 0 && temp>maxValue){
                left = a;
                right = b;
                maxValue = temp;
            }
        }
    }
    if(maxValue == 0){
        printf("0\n");
    } else {
        printf("%d %d %d\n", left, right, maxValue);
    }
}

int main() {
    int n, x, y, z;
    while(scanf("%d %d %d %d", &n, &x, &y, &z)!=EOF) {
        process(n, x, y, z);
    }
    return 0;
}