#include <bits/stdc++.h>
using namespace std;
int a[10][10], b[5010], c[51];
string s[110][110];
int main() {
  int maxx = 0;
  int summ = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a[i][j];
      summ = summ + a[i][j];
    }
  }
  a[1][1] = summ / 6;
  int x = a[1][1] + a[1][0] + a[1][2];
  a[2][2] = abs(x - a[0][2] - a[1][2]);
  a[0][0] = abs(x - a[2][2] - a[1][1]);
  cout << endl;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cout << a[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}
