#include <bits/stdc++.h>
using namespace std;
long long pric[3][3], dp[3][3][50];
long long f(int a, int c, int n) {
  int b;
  if (n == 0) return 0;
  if ((a == 1 && c == 2) || (a == 2 && c == 1))
    b = 0;
  else if ((a == 0 && c == 1) || (c == 0 && a == 1))
    b = 2;
  else
    b = 1;
  if (!dp[a][b][n - 1]) dp[a][b][n - 1] = f(a, b, n - 1);
  if (!dp[b][c][n - 1]) dp[b][c][n - 1] = f(b, c, n - 1);
  if (!dp[a][c][n - 1]) dp[a][c][n - 1] = f(a, c, n - 1);
  if (!dp[c][a][n - 1]) dp[c][a][n - 1] = f(c, a, n - 1);
  dp[a][c][n] =
      min(dp[a][b][n - 1] + dp[b][c][n - 1] + pric[a][c],
          2 * dp[a][c][n - 1] + pric[a][b] + pric[b][c] + dp[c][a][n - 1]);
  return dp[a][c][n];
}
int main() {
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) cin >> pric[i][j];
  int n;
  cin >> n;
  cout << f(0, 2, n);
}
