#include <bits/stdc++.h>
using namespace std;
const int MAXN = 50;
long long t[5][5], dp[MAXN][MAXN][MAXN][MAXN];
long long dfs(int n, int from, int by, int to) {
  if (dp[n][from][by][to] != -1) return dp[n][from][by][to];
  if (n == 1) return min(t[from][to], t[from][by] + t[by][to]);
  long long t1, t2;
  t1 = dfs(n - 1, from, to, by) + t[from][to] + dfs(n - 1, by, from, to);
  t2 = dfs(n - 1, from, by, to) + t[from][by] + dfs(n - 1, to, by, from) +
       t[by][to] + dfs(n - 1, from, by, to);
  return dp[n][from][by][to] = min(t1, t2);
}
int main() {
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= 3; i++)
    for (int j = 1; j <= 3; j++) scanf("%lld", &t[i][j]);
  int n;
  scanf("%d", &n);
  printf("%lld\n", dfs(n, 1, 2, 3));
  return 0;
}
