#include <bits/stdc++.h>
using namespace std;
const long long int INF = 0xFFFFFFFFFFFFFFFL;
const long long int MOD = 1000000007L;
long long int T, n, in, i, m, j, k, ans[50][3][3], p[3][3];
vector<long long int>::iterator it;
long long int check(long long int n, long long int i, long long int j) {
  if (ans[n][i][j] >= 0) {
    return ans[n][i][j];
  }
  if (n == 1) {
    return ans[n][i][j] = min(p[i][j], p[i][3 - i - j] + p[3 - i - j][j]);
  }
  ans[n][i][j] =
      p[i][j] + check(n - 1, i, 3 - i - j) + check(n - 1, 3 - i - j, j);
  ans[n][i][j] = min(ans[n][i][j], 2 * check(n - 1, i, j) + p[i][3 - i - j] +
                                       check(n - 1, j, i) + p[3 - i - j][j]);
  return ans[n][i][j];
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  for (k = 0; k < (50); ++k)
    for (i = 0; i < (3); ++i)
      for (j = 0; j < (3); ++j) ans[k][i][j] = -1;
  for (i = 0; i < (3); ++i)
    for (j = 0; j < (3); ++j) {
      scanf(" %lld", &p[i][j]);
    }
  scanf(" %lld", &n);
  cout << check(n, 0, 2);
  return 0;
}
