#include <bits/stdc++.h>
using namespace std;
long long t[5][5], b[5][5], dp[5][5][50];
long long n;
long long dfs(long long l, long long r, long long n) {
  if (dp[l][r][n]) return dp[l][r][n];
  if (n == 1) return b[l][r];
  int x = 6 - l - r;
  long long res = dfs(l, x, n - 1) + dfs(x, r, n - 1) + t[l][r];
  long long res2 =
      (dfs(l, r, n - 1) << 1) + dfs(r, l, n - 1) + t[l][x] + t[x][r];
  return dp[l][r][n] = min(res, res2);
}
int main() {
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) {
      scanf("%lld", &t[i][j]), b[i][j] = t[i][j];
    }
  }
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) {
      if (i != j) {
        for (int k = 1; k <= 3; k++) {
          if (k != i && k != j) {
            b[i][j] = min(b[i][j], b[i][k] + b[k][j]);
          }
        }
      }
    }
  }
  scanf("%lld", &n);
  printf("%lld\n", dfs(1, 3, n));
  return 0;
}
