#include <bits/stdc++.h>
using namespace std;
int v[5][5], sum;
int main() {
  for (int i = 1; i <= 3; i++)
    for (int h = 1; h <= 3; h++) cin >> v[i][h];
  if (v[1][1] == 0) {
    for (int i = 1; i <= 100000; i++) {
      int a = v[2][1] + v[2][3] - i;
      if (a + v[1][2] + v[1][3] == v[3][1] + v[3][2] + i) {
        v[1][1] = a, v[3][3] = i,
        v[2][2] = v[3][1] + v[3][2] + i - v[2][1] - v[2][3];
        break;
      }
    }
    for (int i = 1; i <= 3; i++) {
      for (int h = 1; h <= 3; h++) cout << v[i][h] << " ";
      cout << "\n";
    }
    return 0;
  }
  for (int i = 1; i <= 100000; i++) {
    int a = v[2][1] + v[2][3] - i;
    if (a + v[1][2] + v[1][1] == v[3][2] + v[3][3] + i) {
      v[1][3] = a, v[3][1] = i,
      v[2][2] = v[3][2] + v[3][3] + i - v[2][1] - v[2][3];
      break;
    }
  }
  for (int i = 1; i <= 3; i++) {
    for (int h = 1; h <= 3; h++) cout << v[i][h] << " ";
    cout << "\n";
  }
}
