#include <bits/stdc++.h>
using namespace std;
int n;
int a[10][10];
long long dp[50][5][5];
long long ans = 0;
long long hanoi(int h, int f, int t) {
  if (dp[h][f][t] != 0) {
    return dp[h][f][t];
  }
  if (h == 1) {
    return dp[h][f][t] = min(a[f][t], a[f][f ^ t] + a[f ^ t][t]);
  } else {
    long long tmp1 = 0, tmp2 = 0;
    tmp1 += hanoi(h - 1, f, f ^ t);
    tmp1 += a[f][t];
    tmp1 += hanoi(h - 1, f ^ t, t);
    tmp2 += hanoi(h - 1, f, t);
    tmp2 += a[f][f ^ t];
    tmp2 += hanoi(h - 1, t, f);
    tmp2 += a[f ^ t][t];
    tmp2 += hanoi(h - 1, f, t);
    return dp[h][f][t] = min(tmp1, tmp2);
  }
}
int main() {
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  scanf("%d", &n);
  memset(dp, 0, sizeof(dp));
  ans = hanoi(n, 1, 3);
  printf("%I64d\n", ans);
  return 0;
}
