#include <bits/stdc++.h>
using namespace std;
int tu(int val) { return (1 << val); }
bool iset(int mask, int id) {
  if ((mask & tu(id)) != 0) return true;
  return false;
}
void doset(int &mask, int id) { mask |= tu(id); }
void dounset(int &mask, int id) { mask = mask & (~tu(id)); }
template <typename T>
string tos(T a) {
  stringstream ss;
  string ret;
  ss << a;
  ss >> ret;
  return ret;
}
vector<vector<int> > res, ins;
bool done = false;
bool ok(vector<vector<int> > arr) {
  int s = 0;
  for (int(i) = (0); (i) < (3); (i)++) s += arr[0][i];
  for (int(r) = (0); (r) < (3); (r)++) {
    int sum = 0;
    for (int(c) = (0); (c) < (3); (c)++) sum += arr[r][c];
    if (sum != s) return false;
  }
  for (int(c) = (0); (c) < (3); (c)++) {
    int sum = 0;
    for (int(r) = (0); (r) < (3); (r)++) sum += arr[r][c];
    if (sum != s) return false;
  }
  int sum = 0;
  for (int(i) = (0); (i) < (3); (i)++) sum += arr[i][i];
  if (sum != s) return false;
  sum = 0;
  for (int(i) = (0); (i) < (3); (i)++) sum += arr[2 - i][i];
  if (sum != s) return false;
  return true;
}
bool valid(int n) {
  if (n >= 1 && n <= 100000) return true;
  return false;
}
void calc(int sum) {
  bool change = true;
  vector<vector<int> > in = ins;
  int llp = 0;
  while (change) {
    change = false;
    for (int(r) = (0); (r) < (3); (r)++) {
      int x, y;
      int ll = 0;
      int s = 0;
      for (int(c) = (0); (c) < (3); (c)++) {
        if (in[r][c] == 0) {
          ll++;
          x = r;
          y = c;
        }
        s += in[r][c];
      }
      if (ll == 1 && valid(sum - s)) {
        in[x][y] = sum - s;
        change = true;
      }
    }
    for (int(c) = (0); (c) < (3); (c)++) {
      int x, y;
      int ll = 0;
      int s = 0;
      for (int(r) = (0); (r) < (3); (r)++) {
        if (in[r][c] == 0) {
          ll++;
          x = r;
          y = c;
        }
        s += in[r][c];
      }
      if (ll == 1 && valid(sum - s)) {
        in[x][y] = sum - s;
        change = true;
      }
    }
    int x, y;
    int ll = 0;
    int s = 0;
    for (int(i) = (0); (i) < (3); (i)++) {
      if (in[i][i] == 0) {
        ll++;
        x = i;
        y = i;
      }
      s += in[i][i];
    }
    if (ll == 1 && valid(sum - s)) {
      in[x][y] = sum - s;
      change = true;
    }
    ll = 0;
    s = 0;
    for (int(i) = (0); (i) < (3); (i)++) {
      if (in[2 - i][i] == 0) {
        ll++;
        x = 2 - i;
        y = i;
      }
      s += in[2 - i][i];
    }
    if (ll == 1 && valid(sum - s)) {
      in[x][y] = sum - s;
      change = true;
    }
  }
  if (ok(in)) {
    done = true;
    res = in;
  }
}
int main() {
  int aa;
  for (int(i) = (0); (i) < (3); (i)++) {
    vector<int> ns;
    for (int(j) = (0); (j) < (3); (j)++) {
      cin >> aa;
      ns.push_back(aa);
    }
    ins.push_back(ns);
  }
  int LIM = 300009;
  for (int(i) = (1); (i) < (LIM); (i)++) {
    if (done == false) calc(i);
  }
  for (int(r) = (0); (r) < (3); (r)++) {
    for (int(c) = (0); (c) < (3); (c)++) {
      if (c > 0) cout << " ";
      cout << res[r][c];
    }
    cout << endl;
  }
  return 0;
}
