#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, t, m, x;
  vector<vector<int> > v;
  vector<int> b;
  int S = 0, ind;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> x;
      b.push_back(x);
    }
    v.push_back(b);
    b.clear();
  }
  m = accumulate(v[0].begin(), v[0].end(), 0);
  k = accumulate(v[1].begin(), v[1].end(), 0);
  int d = m - k;
  if (d > 0) {
    S = m;
    ind = 0;
  } else {
    d *= -1;
    S = accumulate(v[2].begin(), v[2].end(), 0);
    ind = 2;
  }
  x = (S - (3 * d)) / 2;
  if (ind == 0) {
    v[0][0] = x;
    v[1][1] = x + d;
    v[2][2] = x + 2 * d;
  }
  if (ind == 2) {
    v[0][0] = x + 2 * d;
    v[1][1] = x + d;
    v[2][2] = x;
  }
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cout << v[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
