#include <bits/stdc++.h>
using namespace std;
long long a[5][5];
long long dp[44][5][5];
int main() {
  int i, j, n, t, k;
  long long x, y;
  for (i = 0; i < 3; i++)
    for (j = 0; j < 3; j++) cin >> a[i][j];
  cin >> n;
  for (i = 0; i < 3; i++)
    for (j = 0; j < 3; j++) {
      if (i == j) continue;
      t = 3 - i - j;
      if (a[i][j] > a[i][t] + a[t][j])
        dp[1][i][j] = a[i][t] + a[t][j];
      else
        dp[1][i][j] = a[i][j];
    }
  for (k = 2; k <= n; k++) {
    for (i = 0; i < 3; i++)
      for (j = 0; j < 3; j++) {
        if (i == j) continue;
        t = 3 - i - j;
        x = a[i][j] + dp[k - 1][i][t] + dp[k - 1][t][j];
        y = a[i][t] + a[t][j] + dp[k - 1][i][j] * 2 + dp[k - 1][j][i];
        if (x > y)
          dp[k][i][j] = y;
        else
          dp[k][i][j] = x;
      }
  }
  cout << dp[n][0][2] << endl;
  ;
  return 0;
}
