#include <bits/stdc++.h>
using namespace std;
int m[3][3];
int main() {
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> m[i][j];
    }
  }
  for (int i = 1; i <= 100000; ++i) {
    m[1][1] = i;
    int s = m[0][2] + m[1][1] + m[2][0];
    m[0][0] = s - m[1][0] - m[2][0];
    m[2][2] = s - m[2][0] - m[2][1];
    if (m[0][0] == 0 || m[2][2] == 0) continue;
    bool magic = m[0][0] + m[1][1] + m[2][2] == s;
    for (int j = 0; j < 3 && magic; ++j) {
      if (s != m[j][0] + m[j][1] + m[j][2]) magic = 0;
      if (s != m[0][j] + m[1][j] + m[2][j]) magic = 0;
    }
    if (magic) break;
  }
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cout << m[i][j] << " \n"[j == 2];
    }
  }
  return 0;
}
