#include <bits/stdc++.h>
using namespace std;
const int N = 2000 + 5;
int n, m, g[N][N], deg[N];
long long ans;
int main(int argc, char **argv) {
  int x;
  scanf("%d%d", &n, &m);
  if (m != 2) {
    for (int i = 1; i < n; ++i)
      for (int j = i + 1; j <= n; ++j) {
        scanf("%d", &x);
        if (~x) ans += x;
      }
    cout << ans * 2 / n << endl;
  } else {
    for (int i = 1; i < n; ++i)
      for (int j = i + 1; j <= n; ++j) {
        scanf("%d", &g[i][j]);
        if (~g[i][j]) ++deg[i], ++deg[j];
      }
    for (int i = 1; i < n; ++i)
      for (int j = i + 1; j <= n; ++j)
        if (~g[i][j])
          if (deg[i] == 2 && deg[j] == 2)
            ans += g[i][j] << 1;
          else
            ans += g[i][j] * (long long)(n - 1);
    cout << ans / (n * (long long)(n - 1) >> 1) << endl;
  }
  return 0;
}
