#include <bits/stdc++.h>
using namespace std;
long long n, v[4][4], f[45][4][4];
inline long long read() {
  long long ret = 0, ff = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') ff = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    ret = ret * 10 + (ch ^ 48);
    ch = getchar();
  }
  return ret * ff;
}
void write(long long x) {
  if (x < 0) {
    x = -x, putchar('-');
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + 48);
}
void writeln(long long x) { write(x), puts(""); }
void writesp(long long x) { write(x), putchar(' '); }
long long dif(long long x, long long y) { return 6 - x - y; }
long long dp(long long now, long long x, long long y) {
  if (f[now][x][y] != -1) return f[now][x][y];
  if (now == 1)
    return min(v[x][y], v[x][dif(x, y)] + v[dif(x, y)][y]);
  else {
    long long res = 1e9;
    res = min(dp(now - 1, x, dif(x, y)) + dp(now - 1, dif(x, y), y) + v[x][y],
              dp(now - 1, x, y) * 2 + dp(now - 1, y, x) + v[x][dif(x, y)] +
                  v[dif(x, y)][y]);
    return f[now][x][y] = res;
  }
}
signed main() {
  for (long long i = 1; i <= 3; i++)
    for (long long j = 1; j <= 3; j++) v[i][j] = read();
  n = read();
  memset(f, -1, sizeof(f));
  write(dp(n, 1, 3));
  return 0;
}
