#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t[4][4];
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= 3; j++) {
      cin >> t[i][j];
    }
  }
  cin >> n;
  long long int dp[n + 1][4][4];
  dp[1][1][2] = min(t[1][2], t[1][3] + t[3][2]);
  dp[1][1][3] = min(t[1][3], t[1][2] + t[2][3]);
  dp[1][2][1] = min(t[2][1], t[2][3] + t[3][1]);
  dp[1][2][3] = min(t[2][3], t[2][1] + t[1][3]);
  dp[1][3][1] = min(t[3][1], t[3][2] + t[2][1]);
  dp[1][3][2] = min(t[3][2], t[3][1] + t[1][2]);
  for (int i = 2; i <= n; i++) {
    dp[i][1][2] =
        min(dp[i - 1][1][3] + t[1][2] + dp[i - 1][3][2],
            2 * dp[i - 1][1][2] + t[1][3] + dp[i - 1][2][1] + t[3][2]);
    dp[i][1][3] =
        min(dp[i - 1][1][2] + t[1][3] + dp[i - 1][2][3],
            2 * dp[i - 1][1][3] + t[1][2] + dp[i - 1][3][1] + t[2][3]);
    dp[i][2][3] =
        min(dp[i - 1][2][1] + t[2][3] + dp[i - 1][1][3],
            2 * dp[i - 1][2][3] + t[2][1] + dp[i - 1][3][2] + t[1][3]);
    dp[i][2][1] =
        min(dp[i - 1][2][3] + t[2][1] + dp[i - 1][3][1],
            2 * dp[i - 1][2][1] + t[2][3] + dp[i - 1][1][2] + t[3][1]);
    dp[i][3][1] =
        min(dp[i - 1][3][2] + t[3][1] + dp[i - 1][2][1],
            2 * dp[i - 1][3][1] + t[3][2] + dp[i - 1][1][3] + t[2][1]);
    dp[i][3][2] =
        min(dp[i - 1][3][1] + t[3][2] + dp[i - 1][1][2],
            2 * dp[i - 1][3][2] + t[3][1] + dp[i - 1][2][3] + t[1][2]);
  }
  cout << dp[n][1][3] << endl;
}
