#include <bits/stdc++.h>
using namespace std;
long long n;
long long f[4][4][41], a[4][4], b[4][4];
long long dfs(long long l, long long r, long long n) {
  if (f[l][r][n]) return f[l][r][n];
  if (n == 1) return b[l][r];
  long long x = 6 - l - r;
  long long an1 = dfs(l, x, n - 1) + dfs(x, r, n - 1) + a[l][r];
  long long an2 = (dfs(l, r, n - 1) * 2) + dfs(r, l, n - 1) + a[l][x] + a[x][r];
  return f[l][r][n] = min(an1, an2);
}
int main() {
  for (long long i = 1; i <= 3; i++)
    for (long long j = 1; j <= 3; j++) {
      cin >> a[i][j];
      if (i == j) a[i][j] = 0;
      b[i][j] = a[i][j];
    }
  cin >> n;
  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 (i != k && j != k) b[i][j] = min(b[i][j], b[i][k] + b[k][j]);
        }
  cout << dfs(1, 3, n) << endl;
  return 0;
}
