#include <bits/stdc++.h>
using namespace std;
int t[3][3];
long long tower[41][3][3];
long long move(int n, int A, int C) {
  if (tower[n][A][C] < 0) {
    int B = 3 - A - C;
    if (tower[n - 1][A][C] < 0) {
      tower[n - 1][A][C] =
          min(move(n - 1, A, C), move(n - 1, A, B) + move(n - 1, B, C));
      tower[n - 1][A][B] =
          min(move(n - 1, A, B), move(n - 1, A, C) + move(n - 1, C, B));
      tower[n - 1][B][A] =
          min(move(n - 1, B, A), move(n - 1, B, C) + move(n - 1, C, A));
      tower[n - 1][B][C] =
          min(move(n - 1, B, C), move(n - 1, B, A) + move(n - 1, A, C));
      tower[n - 1][C][A] =
          min(move(n - 1, C, A), move(n - 1, C, B) + move(n - 1, B, A));
      tower[n - 1][C][B] =
          min(move(n - 1, C, B), move(n - 1, C, A) + move(n - 1, C, B));
    }
    long long res = tower[n - 1][A][B] + t[A][C] + tower[n - 1][B][C];
    long long res2 = 2 * tower[n - 1][A][C] + t[A][B];
    if (res2 < res) {
      long long res3 = res2;
      res2 += tower[n - 1][C][A] + t[B][C];
      res3 += tower[n - 1][C][B];
      if (res3 < res2) {
        res3 += tower[n - 1][B][A] + t[B][C];
        res2 = min(res2, res3);
      }
      res = min(res, res2);
    }
    tower[n][A][C] = res;
  }
  return tower[n][A][C];
}
int main() {
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) cin >> t[i][j];
  int n;
  cin >> n;
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
      tower[1][i][j] =
          (i == j) ? 0 : min(t[i][j], t[i][3 - i - j] + t[3 - i - j][j]);
  for (int l = 2; l <= n; l++) {
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++) tower[l][i][j] = (i == j) ? 0 : -1;
  }
  move(n, 0, 2);
  move(n, 0, 1);
  move(n, 1, 2);
  cout << min(tower[n][0][2], tower[n][0][1] + tower[n][1][2]);
  return 0;
}
