#include <bits/stdc++.h>
using namespace std;
int main() {
  int t[3][3];
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) cin >> t[i][j];
  int n;
  cin >> n;
  long long dp[45][3][3];
  for (int i = 0; i <= n; i++)
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++) {
        if (i == 0 || j == k)
          dp[i][j][k] = 0;
        else
          dp[i][j][k] = 1000000000000000000;
      }
  for (int disk = 1; disk <= n; disk++)
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++) {
        if (i == j) continue;
        int rod = 3 - i - j;
        dp[disk][i][j] = min(dp[disk][i][j], dp[disk - 1][i][rod] + t[i][j] +
                                                 dp[disk - 1][rod][j]);
        dp[disk][i][j] =
            min(dp[disk][i][j], dp[disk - 1][i][j] + t[i][rod] +
                                    dp[disk - 1][j][i] + t[rod][j] +
                                    dp[disk - 1][i][j]);
      }
  cout << dp[n][0][2] << "\n";
  return 0;
}
