#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int inf = 0x3f3f3f3f;
const long long inf64 = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-6;
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& p) {
  return os << p.first << "," << p.second;
}
template <typename A>
ostream& operator<<(ostream& os, const vector<A>& v) {
  for (int i = 0; i < v.size(); i++) {
    os << v[i] << ";";
  }
  return os;
}
template <typename A>
ostream& operator<<(ostream& os, const set<A>& v) {
  for (typename set<A>::const_iterator it = v.begin(); it != v.end(); ++it) {
    os << *it << ";";
  }
  return os;
}
template <typename A, typename B>
ostream& operator<<(ostream& os, const map<A, B>& v) {
  for (typename map<A, B>::const_iterator it = v.begin(); it != v.end(); ++it) {
    os << it->first << "=" << it->second << ";";
  }
  return os;
}
int a[3][3];
int row[3];
int col[3];
int diag[2];
int hasrow[3];
int hascol[3];
int hasdiag[2];
void add(int i, int j, int need) {
  a[i][j] = need;
  row[i] += need;
  hasrow[i]++;
  col[j] += need;
  hascol[j]++;
  if (i == j) {
    diag[0] += need;
    hasdiag[0]++;
  }
  if (i + j == 2) {
    diag[1] += need;
    hasdiag[1]++;
  }
}
void del(int i, int j, int need) {
  a[i][j] = 0;
  row[i] -= need;
  hasrow[i]--;
  col[j] -= need;
  hascol[j]--;
  if (i == j) {
    diag[0] -= need;
    hasdiag[0]--;
  }
  if (i + j == 2) {
    diag[1] -= need;
    hasdiag[1]--;
  }
}
void check(int s, int t = 6) {
  if (t == 9) {
    for (int i = 0; i < 3; i++) {
      if (row[i] != s) {
        return;
      }
      if (col[i] != s) {
        return;
      }
      if (diag[0] != s) {
        return;
      }
      if (diag[1] != s) {
        return;
      }
    }
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        printf("%d ", a[i][j]);
      }
      puts("");
    }
    exit(0);
  }
  for (int i = 0; i < 3; i++) {
    if (row[i] + 3 - hasrow[i] > s) {
      return;
    }
    if (col[i] + 3 - hascol[i] > s) {
      return;
    }
  }
  if (diag[0] + 3 - hasdiag[0] > s || diag[1] + 3 - hasdiag[1] > s) return;
  for (int i = 0; i < 3; i++) {
    if (hasrow[i] == 2) {
      for (int j = 0; j < 3; j++) {
        if (!a[i][j]) {
          long long need = s - row[i];
          add(i, j, need);
          check(s, t + 1);
          del(i, j, need);
        }
      }
    }
    if (hascol[i] == 2) {
      for (int j = 0; j < 3; j++) {
        if (!a[j][i]) {
          int need = s - col[j];
          add(j, i, need);
          check(s, t + 1);
          del(j, i, need);
        }
      }
    }
    if (hasdiag[0] == 2) {
      for (int j = 0; j < 3; j++) {
        if (!a[j][j]) {
          int need = s - diag[0];
          add(j, j, need);
          check(s, t + 1);
          del(j, j, need);
        }
      }
    }
    if (hasdiag[1] == 2) {
      for (int j = 0; j < 3; j++) {
        if (!a[j][2 - j]) {
          int need = s - diag[1];
          add(j, 2 - j, need);
          check(s, t + 1);
          del(j, 2 - j, need);
        }
      }
    }
  }
}
int main() {
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      scanf("%d", &a[i][j]);
      if (!a[i][j]) {
      } else {
        hasrow[i]++;
        hascol[j]++;
        if (i == j) {
          hasdiag[0]++;
        }
        if (i + j == 2) {
          hasdiag[1]++;
        }
      }
      row[i] += a[i][j];
      col[j] += a[i][j];
      if (i == j) {
        diag[0] += a[i][j];
      }
      if (i + j == 2) {
        diag[1] += a[i][j];
      }
    }
  }
  for (int s = 3; s <= (1 << 20); s++) {
    check(s);
  }
  return 0;
}
