#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int arr[5][5];
  int top, mid, bottom;
  int x;
  for (int i = 0; i < 3; ++i) {
    int t = 0;
    for (int j = 0; j < 3; ++j) {
      cin >> arr[i][j];
      t += arr[i][j];
    }
    if (i == 0)
      top = t;
    else if (i == 1)
      mid = t;
    else
      bottom = t;
  }
  int maks = max(top, max(mid, bottom));
  int diagonal = 3 * maks - top - mid - bottom + 3;
  int tengah = maks - mid + 1;
  arr[0][0] = maks - top + 1;
  arr[1][1] = tengah;
  arr[2][2] = maks - bottom + 1;
  int t = arr[0][2] + arr[2][0];
  int cnt = 0;
  while (1) {
    if (t + tengah + cnt == diagonal + 3 * cnt) break;
    cnt++;
  }
  for (int i = 0; i < 3; ++i) arr[i][i] += cnt;
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      if (j) cout << " ";
      cout << arr[i][j];
    }
    cout << endl;
  }
  return 0;
}
