#include <bits/stdc++.h>
using namespace std;
void _fill_int(int* p, int val, int rep) {
  int i;
  for (i = 0; i < rep; i++) p[i] = val;
}
signed long long GETi() {
  signed long long i;
  scanf("%lld", &i);
  return i;
}
int T[3][3], N;
signed long long dpdp[41][3][3];
signed long long calc(int n, int s, int e) {
  int t = 3 - s - e;
  if (n == 1) return min(T[s][e], T[s][t] + T[t][e]);
  if (dpdp[n][s][e] == -1) {
    int t = 3 - s - e;
    dpdp[n][s][e] = min(calc(n - 1, s, t) + T[s][e] + calc(n - 1, t, e),
                        calc(n - 1, s, e) + T[s][t] + calc(n - 1, e, s) +
                            T[t][e] + calc(n - 1, s, e));
  }
  return dpdp[n][s][e];
}
void solve() {
  int f, i, j, k, l, x, y;
  cin >> T[0][0] >> T[0][1] >> T[0][2];
  cin >> T[1][0] >> T[1][1] >> T[1][2];
  cin >> T[2][0] >> T[2][1] >> T[2][2];
  cin >> N;
  for (i = 0; i < N + 1; i++)
    for (x = 0; x < 3; x++)
      for (y = 0; y < 3; y++) dpdp[i][x][y] = -1;
  cout << min(calc(N, 0, 2), calc(N, 0, 1) + calc(N, 1, 2)) << endl;
}
int main(int argc, char** argv) {
  string s;
  if (argc == 1) ios::sync_with_stdio(false);
  for (int i = 1; i < argc; i++) s += argv[i], s += '\n';
  for (int i = s.size() - 1; i >= 0; i--) ungetc(s[i], stdin);
  solve();
  return 0;
}
