#include <bits/stdc++.h>
using namespace std;
int n, a, dif;
int arr[3][3];
vector<int> vc;
int main() {
  bool flag = false;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> arr[i][j];
      a += arr[i][j];
    }
    vc.push_back(a);
    a = 0;
  }
  dif = vc[0] - vc[1];
  if (dif < 0) dif = abs(dif), flag = true;
  n = (vc[0] + vc[1] + vc[2]) / 6;
  if (flag)
    arr[0][0] = n + dif, arr[1][1] = n, arr[2][2] = n - dif;
  else
    arr[2][2] = n + dif, arr[1][1] = n, arr[0][0] = n - dif;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cout << arr[i][j] << " ";
    }
    cout << "\n";
  }
}
