#include <bits/stdc++.h>
using namespace std;
long long dp[42][3][3];
long long cost[3][3];
long long rec(int n, int from, int to) {
  if (n == 0) return 0;
  long long &ret = dp[n][from][to];
  if (ret != -1) return ret;
  int aux = 3 - from - to;
  long long way1 = rec(n - 1, from, aux) + cost[from][to] + rec(n - 1, aux, to);
  long long way2 = 2 * rec(n - 1, from, to) + cost[from][aux] +
                   rec(n - 1, to, from) + cost[aux][to];
  ret = min(way1, way2);
  return ret;
}
int main() {
  int n;
  memset(dp, -1, sizeof dp);
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) cin >> cost[i][j];
  cin >> n;
  cout << rec(n, 0, 2) << endl;
  return 0;
}
