#include <bits/stdc++.h>
using namespace std;
const long long N = 45, INF = 1e18;
bool vis[N][4][4];
long long a[4][4], dis[4][4], n, dp[N][4][4];
inline void init() {
  for (long long i = 1; i <= 3; i++) {
    for (long long j = 1; j <= 3; j++) {
      scanf("%lld", &a[i][j]);
      dis[i][j] = a[i][j];
    }
  }
  for (long long i = 1; i <= 3; i++) {
    for (long long j = 1; j <= 3; j++) {
      if (i != j) {
        for (long long k = 1; k <= 3; k++) {
          if (k != i && k != j)
            dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
        }
      }
    }
  }
  scanf("%lld", &n);
}
inline long long dfs(long long k, long long x, long long y) {
  if (vis[k][x][y]) return dp[k][x][y];
  if (k == 1) return dis[x][y];
  vis[k][x][y] = 1;
  long long &ans = dp[k][x][y];
  ans = INF;
  long long o = 6 - x - y;
  ans = min(ans, dfs(k - 1, x, o) + a[x][y] + dfs(k - 1, o, y));
  ans = min(ans, dfs(k - 1, x, y) * 2 + a[x][o] + dfs(k - 1, y, x) + a[o][y]);
  return ans;
}
inline void solve() { printf("%lld\n", dfs(n, 1, 3)); }
signed main() {
  init();
  solve();
  return 0;
}
