#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, e, f, g[5][5], h, i, j, k;
long long F[55][5][5][5];
long long soso(long long x, long long left, long long mid, long long right) {
  if (F[x][left][mid][right] >= 0) return F[x][left][mid][right];
  if (x == 1) return min(g[left][mid] + g[mid][right], g[left][right]);
  long long t1 = soso(x - 1, left, right, mid) + g[left][right] +
                 soso(x - 1, mid, left, right);
  long long t2 = soso(x - 1, left, mid, right) + g[left][mid] +
                 soso(x - 1, right, mid, left) + g[mid][right] +
                 soso(x - 1, left, mid, right);
  return F[x][left][mid][right] = min(t1, t2);
}
int main() {
  for (i = 1; i <= 3; i++)
    for (j = 1; j <= 3; j++) cin >> g[i][j];
  cin >> a;
  memset(F, -1, sizeof(F));
  cout << soso(a, 1, 2, 3) << endl;
  return 0;
}
