#include <bits/stdc++.h>
using namespace std;
int n;
int k;
int G[2010][2010];
int deg[2020];
long long dsum[2010];
long long sum = 0;
int main() {
  scanf("%d%d", &n, &k);
  if (k >= 4 && k != 1 && k != n - 1) {
    printf("0\n");
    return 0;
  }
  for (register int i = 1; i <= n; i++) {
    for (register int j = i + 1; j <= n; j++) {
      scanf("%d", &G[i][j]);
      if (G[i][j] != -1) {
        deg[i]++;
        deg[j]++;
        sum += G[i][j];
        dsum[i] += G[i][j];
        dsum[j] += G[i][j];
      }
      G[j][i] = G[i][j];
    }
  }
  if (k == n - 1) {
    bool ok = true;
    if (!ok) {
      printf("0\n");
      return 0;
    }
    sum *= 2;
    long long t = n;
    printf("%lld\n", sum / t);
  } else if (k == 1) {
    bool ok = true;
    ok = ((n % 2) == 0);
    for (register int i = 1; i <= n && ok; i++) {
      if (deg[i] != 1) {
        ok = false;
        break;
      }
    }
    if (!ok) {
      printf("0\n");
      return 0;
    }
    sum *= 2;
    long long t = n;
    printf("%lld\n", sum / t);
  } else if (k == 2) {
    long long tot = 0;
    for (register int i = 1; i <= n; i++) {
      if (deg[i] > 2) {
        tot += dsum[i] * (n - 2);
      } else {
        tot += dsum[i];
      }
    }
    printf("%lld\n", tot / (n * (n - 1) / 2));
  } else {
    printf("0\n");
  }
  return 0;
}
