#include <bits/stdc++.h>
using namespace std;
long long n, i, j, a[4][4], f[41][4][5];
long long minn(long long a, long long b) {
  if (a < b) return a;
  return b;
}
int main() {
  for (i = 1; i <= 3; i++)
    for (j = 1; j <= 3; j++) {
      scanf("%I64d", &a[i][j]);
    }
  scanf("%I64d", &n);
  f[1][1][3] = minn(a[1][2] + a[2][3], a[1][3]);
  f[1][1][2] = minn(a[1][2], a[1][3] + a[3][2]);
  f[1][2][1] = minn(a[2][3] + a[3][1], a[2][1]);
  f[1][2][3] = minn(a[2][3], a[2][1] + a[1][3]);
  f[1][3][1] = minn(a[3][2] + a[2][1], a[3][1]);
  f[1][3][2] = minn(a[3][2], a[3][1] + a[1][2]);
  for (i = 2; i <= n; i++) {
    f[i][1][2] = minn(f[i - 1][1][3] + a[1][2] + f[i - 1][3][2],
                      2 * f[i - 1][1][2] + a[1][3] + f[i - 1][2][1] + a[3][2]);
    f[i][1][3] = minn(f[i - 1][1][2] + a[1][3] + f[i - 1][2][3],
                      2 * f[i - 1][1][3] + a[1][2] + f[i - 1][3][1] + a[2][3]);
    f[i][2][1] = minn(f[i - 1][2][3] + a[2][1] + f[i - 1][3][1],
                      2 * f[i - 1][2][1] + a[2][3] + f[i - 1][1][2] + a[3][1]);
    f[i][2][3] = minn(f[i - 1][2][1] + a[2][3] + f[i - 1][1][3],
                      2 * f[i - 1][2][3] + a[2][1] + f[i - 1][3][2] + a[1][3]);
    f[i][3][1] = minn(f[i - 1][3][2] + a[3][1] + f[i - 1][2][1],
                      2 * f[i - 1][3][1] + a[3][2] + f[i - 1][1][3] + a[2][1]);
    f[i][3][2] = minn(f[i - 1][3][1] + a[3][2] + f[i - 1][1][2],
                      2 * f[i - 1][3][2] + a[3][1] + f[i - 1][2][3] + a[1][2]);
  }
  printf("%I64d", f[n][1][3]);
}
