#include <bits/stdc++.h>
using namespace std;
const int N = 10005;
int val[4][4];
long long dp[N][4][4][4];
long long dfs(int cont, int r1, int r2, int r3) {
  if (cont == 0) return 0;
  long long &res = dp[cont][r1][r2][r3];
  if (res >= 0) return res;
  long long ret1 =
      dfs(cont - 1, r1, r3, r2) + val[r1][r3] + dfs(cont - 1, r2, r1, r3);
  long long ret2 = dfs(cont - 1, r1, r2, r3) * 2 + dfs(cont - 1, r3, r2, r1) +
                   val[r1][r2] + val[r2][r3];
  res = min(ret1, ret2);
  return res;
}
int main() {
  int n;
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= 3; i++)
    for (int j = 1; j <= 3; j++) cin >> val[i][j];
  cin >> n;
  long long ans = dfs(n, 1, 2, 3);
  cout << ans << endl;
  return 0;
}
