#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e3 + 10;
long long ans, rem, n, k, arr[MAXN][MAXN], num[MAXN];
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> k;
  if (k != 2) {
    for (int i = 1; i < n; i++) {
      for (int j = i; j < n; j++) {
        long long pp;
        cin >> pp;
        if (!(~pp)) continue;
        ans += pp / n;
        rem += pp % n;
      }
    }
    cout << 2 * ans + (2 * rem) / n << endl;
    return 0;
  }
  long long me = (n * (n - 1)) / 2;
  for (int i = 1; i < n; i++) {
    for (int j = i; j < n; j++) {
      cin >> arr[i][j];
      if (!(~arr[i][j])) continue;
      num[i]++;
      num[j + 1]++;
    }
  }
  for (int i = 1; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (!(~arr[i][j])) continue;
      ans += (arr[i][j] * (num[i] - 1 + num[j + 1] - 1)) / me;
      rem += (arr[i][j] * (num[i] - 1 + num[j + 1] - 1)) % me;
    }
  }
  cout << ans + rem / me << endl;
  return 0;
}
