#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[5][5];
  int sum[5];
  memset(sum, 0, sizeof(sum));
  for (int i = 1; i <= 3; i++)
    for (int j = 1; j <= 3; j++) {
      cin >> a[i][j];
      sum[i] += a[i][j];
    }
  int max = 0, pos;
  for (int i = 1; i <= 3; i++) {
    if (sum[i] > max) max = sum[i];
    if (a[1][i] == 0) pos = i;
  }
  int sumx = 0;
  for (int i = 1; i <= 3; i++) {
    sum[i] = max - sum[i] + 1;
    sumx += sum[i];
  }
  int add = 0;
  while (sumx != a[1][1] + a[1][2] + a[1][3] + add + sum[1]) {
    sumx += 3;
    add++;
  }
  for (int i = 1; i <= 3; i++)
    for (int j = 1; j <= 3; j++) {
      if (a[i][j] == 0) a[i][j] = sum[i] + add;
    }
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) {
      if (j != 3)
        cout << a[i][j] << " ";
      else
        cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}
