#include<bits/stdc++.h>
using namespace std;

int n;
int a, b, c;
int main() {
	while (cin >> n>>a>>b>>c) {
		int num = 0;
		num += a * 1000 + b * 100 + c * 10;
		bool b = false;
		for (int i = 9; i > 0; i--) {
			int temp = i * 10000;
			num += temp;
			for (int j = 9; j >= 0; j--) {
				num += j;
				if (num % n == 0) {
					printf("%d %d %d\n", i, j, num / n);
					b = true;
					break;
				}
				num -= j;
			}
			if (b == true) {
				break;
			}
			num -= temp;
		}
		if (b == false)
			printf("0");
	}
	
}