#include <bits/stdc++.h>
using namespace std;
int deg[2505];
int c[2505][2505];
int main() {
  int n, k;
  cin >> n >> k;
  int bad = 0;
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      scanf("%d", &c[i][j]);
      if (c[i][j] == -1) {
        ++bad;
      } else {
        ++deg[i];
        ++deg[j];
        sum += c[i][j];
      }
    }
  }
  if (k == 1) {
    cout << sum / (n / 2) << endl;
  } else if (k == 2 && n != 3) {
    long long ways = n * (n - 1) / 2;
    long long sum = 0;
    int q = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
        if (c[i][j] == -1) {
          continue;
        }
        if (deg[i] > 2 || deg[j] > 2) {
          sum += (long long)c[i][j] * (n - 1);
        } else {
          sum += 2 * c[i][j];
        }
      }
    }
    cout << sum / ways << endl;
  } else {
    if (bad != 0) {
      return 1234567;
    }
    cout << (2 * sum) / n << endl;
  }
  return 0;
}
