import java.util.*;
class Main {
static int[][] impl = new int[][] {
new int[] {1, 2, 4, 5, 0},
new int[] {1, 2, 3, 0, 0},
new int[] {2, 3, 5, 6, 0},
new int[] {1, 4, 7, 0, 0},
new int[] {2, 4, 5, 6, 8},
new int[] {3, 6, 9, 0, 0},
new int[] {4, 5, 7, 8, 0},
new int[] {7, 8, 9, 0, 0},
new int[] {5, 6, 8, 9, 0}};
static int[] cnt;
static List<Integer> list, ans;
public static boolean check() {
for (int i = 1; i <= 9; ++ i) {
if (cnt[i] % 4 != 0) return false;
}
return true;
}
public static void dfs(int x) {
if (x == 9) {
if (check() && (ans == null || list.size() < ans.size())) {
ans = new ArrayList<>(list);
}
return;
}
int k = (4 - cnt[impl[x][0]] % 4) % 4;
for (int t = 0; t < k; ++ t) list.add(x);
for (int t = 0; t < 5; ++ t) cnt[impl[x][t]] += k;
dfs(x + 1);
for (int t = 0; t < 5; ++ t) cnt[impl[x][t]] -= k;
for (int t = 0; t < k; ++ t) list.remove(list.size() - 1);
}
// a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
cnt = new int[10];
for (int i = 1; i <= 9; ++ i) cnt[i] = sc.nextInt() / 3;
for (int i = 0; i < 4; ++ i) {
for (int j = 0; j < 4; ++ j) {
for (int k = 0; k < 4; ++ k) {
list = new ArrayList<>();
for (int t = 0; t < i; ++ t) list.add(0);
for (int t = 0; t < j; ++ t) list.add(1);
for (int t = 0; t < k; ++ t) list.add(2);
for (int t = 0; t < 5; ++ t) {
cnt[impl[0][t]] += i;
cnt[impl[1][t]] += j;
cnt[impl[2][t]] += k;
}
dfs(3);
for (int t = 0; t < 5; ++ t) {
cnt[impl[0][t]] -= i;
cnt[impl[1][t]] -= j;
cnt[impl[2][t]] -= k;
}
}
}
}
for (int num : ans) System.out.print((num + 1) + " ");
}
}