#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = 1E-9;
const int INF = (int)1E9;
int deg[2005];
long long w[2005][2005];
int main() {
  int N, K;
  long long sum = 0, x;
  cin >> N >> K;
  memset(deg, 0, sizeof(deg));
  for (int i = 0; i < (N); i++) {
    for (int j = (i + 1); j <= (N - 1); j++) {
      scanf("%I64d", &w[i][j]);
      if (w[i][j] != -1) {
        deg[i]++;
        deg[j]++;
      }
    }
  }
  for (int i = 0; i < (N); i++) {
    for (int j = (i + 1); j <= (N - 1); j++) {
      if (w[i][j] != -1) {
        if (K == 1 || K == N - 1) {
          sum += w[i][j] * 2;
        } else {
          sum += w[i][j] * (deg[i] + deg[j] - 2);
        }
      }
    }
  }
  cout << sum / (K == 2 ? N * (N - 1) / 2 : N) << endl;
  return 0;
}
