#include <bits/stdc++.h>
using namespace std;
int d[3][3];
long long DP[41][3][3];
int main() {
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> d[i][j];
    }
  }
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    DP[i][0][1] =
        min(DP[i - 1][0][2] + d[0][1] + DP[i - 1][2][1],
            d[0][2] + d[2][1] + 2 * DP[i - 1][0][1] + DP[i - 1][1][0]);
    DP[i][0][2] =
        min(DP[i - 1][0][1] + d[0][2] + DP[i - 1][1][2],
            d[0][1] + d[1][2] + 2 * DP[i - 1][0][2] + DP[i - 1][2][0]);
    DP[i][1][0] =
        min(DP[i - 1][1][2] + d[1][0] + DP[i - 1][2][0],
            d[1][2] + d[2][0] + 2 * DP[i - 1][1][0] + DP[i - 1][0][1]);
    DP[i][1][2] =
        min(DP[i - 1][1][0] + d[1][2] + DP[i - 1][0][2],
            d[1][0] + d[0][2] + 2 * DP[i - 1][1][2] + DP[i - 1][2][1]);
    DP[i][2][0] =
        min(DP[i - 1][2][1] + d[2][0] + DP[i - 1][1][0],
            d[2][1] + d[1][0] + 2 * DP[i - 1][2][0] + DP[i - 1][0][2]);
    DP[i][2][1] =
        min(DP[i - 1][2][0] + d[2][1] + DP[i - 1][0][1],
            d[2][0] + d[0][1] + 2 * DP[i - 1][2][1] + DP[i - 1][1][2]);
  }
  cout << DP[n][0][2] << '\n';
  return 0;
}
