#include <bits/stdc++.h>
using namespace std;
const int maxn = 51, rs = 6;
int n, r = 3, t[5][5];
long long f[maxn][5][5] = {0};
int main() {
  int i, j, r1, r2, r3;
  for (i = 1; i <= r; i++)
    for (j = 1; j <= r; j++) scanf("%d", &t[i][j]);
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    for (r1 = 1; r1 <= r; r1++)
      for (r2 = 1; r2 <= r; r2++)
        if (r1 != r2 && (r3 = rs - r1 - r2))
          f[i][r1][r2] = min(f[i - 1][r1][r3] + t[r1][r2] + f[i - 1][r3][r2],
                             f[i - 1][r1][r2] + t[r1][r3] + f[i - 1][r2][r1] +
                                 t[r3][r2] + f[i - 1][r1][r2]);
  printf("%I64d\n", f[n][1][3]);
  return 0;
}
