#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t[3][3], f[3][3][41];
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> t[i][j];
    }
  }
  int n;
  cin >> n;
  for (int i = 0; i < 3; ++i) {
    for (int j = 0; j < 3; ++j) {
      f[i][j][0] = 0;
    }
  }
  for (int pos = 1; pos <= n; ++pos) {
    for (int i = -1; i <= 1; ++i) {
      for (int j = -1; j <= 1; ++j) {
        if (i == j) continue;
        int k1 = i + 1, k2 = j + 1, k3 = ((i + j) * -1) + 1;
        f[k1][k2][pos] =
            min(f[k1][k3][pos - 1] + t[k1][k2] + f[k3][k2][pos - 1],
                2 * f[k1][k2][pos - 1] + t[k1][k3] + f[k2][k1][pos - 1] +
                    t[k3][k2]);
      }
    }
  }
  cout << f[0][2][n];
  return 0;
}
