public class Test04 {
	public static void main(String[] args) {
		int i, j, n, k, nmg;
		int a[] = new int[5];
		i = 0;
		do
		{
			n = -1;
			i++;
			j = i;
			k = 0;
			do
			{
				k++;
				nmg = j - j / 4 * 4;
				if (nmg != 1)
					break;
				j--;
				n++;
				a[n] = j / 4;
				j = j * 3 / 4;
			} while (k < 5);
		} while (nmg != 1 || k < 5);
		nmg = j + a[4] + 1;
		System.out.printf("%d %d %d %d %d %d", i, a[0], a[1], a[2], a[3], nmg);
	}
}
