#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
long long t[3][3];
long long mat[41][3][3][3];
long long compute(int n, int i, int j, int k) {
  if (mat[n][i][j][k] != -1) return mat[n][i][j][k];
  if (n == 1) {
    mat[n][i][j][k] =
        ((t[i][j]) < (t[i][k] + t[k][j]) ? (t[i][j]) : (t[i][k] + t[k][j]));
    return mat[n][i][j][k];
  }
  long long a = ((compute(n - 1, i, k, j)) <
                         (compute(n - 1, i, j, k) + compute(n - 1, j, k, i))
                     ? (compute(n - 1, i, k, j))
                     : (compute(n - 1, i, j, k) + compute(n - 1, j, k, i)));
  a += t[i][j];
  a += ((compute(n - 1, k, j, i)) <
                (compute(n - 1, k, i, j) + compute(n - 1, i, j, k))
            ? (compute(n - 1, k, j, i))
            : (compute(n - 1, k, i, j) + compute(n - 1, i, j, k)));
  long long b = ((compute(n - 1, i, j, k)) <
                         (compute(n - 1, i, k, j) + compute(n - 1, k, j, i))
                     ? (compute(n - 1, i, j, k))
                     : (compute(n - 1, i, k, j) + compute(n - 1, k, j, i)));
  b += t[i][k] + t[k][j];
  b += compute(n - 1, j, i, k) +
       ((compute(n - 1, i, j, k)) <
                (compute(n - 1, i, k, j) + compute(n - 1, k, j, i))
            ? (compute(n - 1, i, j, k))
            : (compute(n - 1, i, k, j) + compute(n - 1, k, j, i)));
  mat[n][i][j][k] = ((a) < (b) ? (a) : (b));
  return mat[n][i][j][k];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  for (int i = 0; i < 41; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        for (int l = 0; l < 3; l++) {
          mat[i][j][k][l] = -1;
        }
      }
    }
  }
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> t[i][j];
    }
  }
  int n;
  cin >> n;
  cout << compute(n, 0, 2, 1) << "\n";
  return 0;
}
