#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
struct point {
  int v, x;
  point() {}
  point(int v, int x) : v(v), x(x) {}
};
vector<point> v[N];
int main() {
  long long sum = 0;
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int x;
    for (int j = i + 1; j <= n; j++) {
      scanf("%d", &x);
      if (x == -1) continue;
      sum += 2 * x;
      v[i].push_back(point(j, x));
      v[j].push_back(point(i, x));
    }
  }
  if (m >= 3) {
    cout << sum / n << endl;
    return 0;
  }
  if (m == 1) {
    cout << sum / n << endl;
    return 0;
  }
  sum = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < v[i].size(); j++)
      for (int k = j + 1; k < v[i].size(); k++) sum += v[i][j].x + v[i][k].x;
  }
  cout << sum / (n * (n - 1) / 2) << endl;
  return 0;
}
