#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  char c = getchar();
  long long tot = 1;
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') {
    tot = -1;
    c = getchar();
  }
  long long sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum * tot;
}
inline void wr(long long x) {
  if (x < 0) {
    putchar('-');
    wr(-x);
    return;
  }
  if (x >= 10) wr(x / 10);
  putchar(x % 10 + '0');
}
inline void wrn(long long x) {
  wr(x);
  putchar('\n');
}
inline void wri(long long x) {
  wr(x);
  putchar(' ');
}
inline void wrn(long long x, long long y) {
  wri(x);
  wrn(y);
}
inline void wrn(long long a, long long b, long long c) {
  wri(a);
  wrn(b, c);
}
long long n, m, ans;
long long a[1001][1001], b[1001][1001];
long long f[101][101][101];
long long dfs(long long l, long long r, long long n) {
  if (f[l][r][n]) return f[l][r][n];
  if (n == 1) return b[l][r];
  long long x = 6 - l - r;
  long long an1 = dfs(l, x, n - 1) + dfs(x, r, n - 1) + a[l][r];
  long long an2 =
      (dfs(l, r, n - 1) << 1) + dfs(r, l, n - 1) + a[l][x] + a[x][r];
  return f[l][r][n] = min(an1, an2);
}
signed main() {
  for (long long i = 1; i <= 3; i++)
    for (long long j = 1; j <= 3; j++) {
      a[i][j] = read();
      b[i][j] = a[i][j];
    }
  for (long long i = 1; i <= 3; i++)
    for (long long j = 1; j <= 3; j++)
      if (i != j)
        for (long long k = 1; k <= 3; k++)
          if (k != i && k != j) b[i][j] = min(b[i][j], b[i][k] + b[k][j]);
  n = read();
  cout << dfs(1, 3, n);
  return 0;
}
