#include <bits/stdc++.h>
using namespace std;
long long cost[3][3];
long long dp[3][3][41];
int main() {
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j) cin >> cost[i][j];
  int c;
  cin >> c;
  for (int n = 1; n <= c; ++n) {
    for (int from = 0; from < 3; ++from) {
      for (int to = 0; to < 3; ++to) {
        if (from == to) continue;
        int left;
        if (from == 0 && to == 1)
          left = 2;
        else if (from == 0 && to == 2)
          left = 1;
        else if (from == 1 && to == 0)
          left = 2;
        else if (from == 1 && to == 2)
          left = 0;
        else if (from == 2 && to == 0)
          left = 1;
        else if (from == 2 && to == 1)
          left = 0;
        dp[from][to][n] =
            min(dp[from][left][n - 1] + cost[from][to] + dp[left][to][n - 1],
                dp[from][to][n - 1] + cost[from][left] + dp[to][from][n - 1] +
                    cost[left][to] + dp[from][to][n - 1]);
      }
    }
  }
  cout << dp[0][2][c];
  return 0;
}
