#include <bits/stdc++.h>
using namespace std;
long long n, cost(long long, long long, long long), price[41][3][3],
    used[41][3][3], t[3][3];
int main() {
  long long i, j;
  for (i = 0; i < 3; i++)
    for (j = 0; j < 3; j++) cin >> t[i][j];
  cin >> n;
  cout << cost(n, 0, 2);
  return 0;
}
long long cost(long long m, long long from, long long to) {
  long long aux = 3 - from - to, cost1, cost2;
  if (!used[m][from][to]) {
    used[m][from][to] = 1;
    if (m == 1) {
      cost1 = t[from][aux] + t[aux][to];
      cost2 = t[from][to];
    } else {
      cost1 = cost(m - 1, from, aux) + t[from][to] + cost(m - 1, aux, to);
      cost2 = 2 * cost(m - 1, from, to) + cost(m - 1, to, from) + t[from][aux] +
              t[aux][to];
    }
    price[m][from][to] = min(cost1, cost2);
  }
  return price[m][from][to];
}
