#include <bits/stdc++.h>
using namespace std;
long long a[4][4], dp[41][4][4][4], n, i, j;
long long get(int n, int p1, int p2, int p3) {
  if (n == 1) return min(a[p1][p3], a[p1][p2] + a[p2][p3]);
  if (dp[n][p1][p2][p3] != -1) return dp[n][p1][p2][p3];
  long long tmp1 = get(n - 1, p1, p3, p2) + a[p1][p3] + get(n - 1, p2, p1, p3);
  long long tmp2 = get(n - 1, p1, p2, p3) + a[p1][p2] + get(n - 1, p3, p2, p1) +
                   a[p2][p3] + get(n - 1, p1, p2, p3);
  dp[n][p1][p2][p3] = min(tmp1, tmp2);
  return dp[n][p1][p2][p3];
}
int main() {
  memset(dp, -1, sizeof(dp));
  for (i = 1; i <= 3; i++)
    for (j = 1; j <= 3; j++) scanf("%d", &a[i][j]);
  scanf("%d", &n);
  cout << get(n, 1, 2, 3) << endl;
}
