#include <bits/stdc++.h>
using namespace std;
int a[4][4];
bool check(int x) {
  int r[2][4];
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 4; j++) r[i][j] = 0;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) r[0][i] += a[i][j];
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) r[1][i] += a[j][i];
  r[0][3] += a[0][0] + a[1][1] + a[2][2];
  r[1][3] += a[0][2] + a[1][1] + a[2][0];
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 4; j++)
      if (r[i][j] != r[0][0]) return 0;
  return 1;
}
int main() {
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) cin >> a[i][j];
  int ans;
  for (int i = 1; i < 1000 * 100 + 1; i++) {
    int qq = 0;
    a[0][0] = i;
    int yu = a[0][0] + a[0][1] + a[0][2];
    for (int k = 1; k < 3; k++) {
      int oo = 0;
      for (int j = 0; j < 3; j++) oo += a[k][j];
      a[k][k] = yu - oo;
    }
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++)
        if (a[i][j] < 0) qq++;
    if (qq > 0) continue;
    if (check(i)) break;
    a[0][0] = 0;
    a[1][1] = 0;
    a[2][2] = 0;
  }
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) cout << a[i][j] << " ";
    cout << endl;
  }
  return 0;
}
