#include<cstdio> int main(){ int n; while (scanf("%d", &n) != EOF){ int a1,a2,a3; scanf("%d %d %d", &a1,&a2,&a3); int i = 9; bool flag = false; for (; i > 0; i--){ for (int j=9; j >= 0; j--){ int m = i * 10000 + a1 * 1000 + a2 * 100 + a3 * 10 + j; if (m%n == 0){ printf("%d %d %d\n", i, j, m / n); flag = true; break; } } if (flag == true){ break; } } if (i == 0){ printf("0\n"); } } }