#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int Maxn = 4005, Maxm = 300005, Mo = 10007,
          sp[8][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const long long oo = INT_MAX;
struct Tree {
  int l, r, cnt;
};
struct edge {
  int u, v, len;
};
struct node {
  int x, y, id;
};
typedef int IArr[Maxn];
typedef long long LArr[Maxn];
typedef double DArr[Maxn];
LArr s, c;
int n, m, i, j, k, a;
long long ans;
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> k;
  for (i = 1; n - i + 1; i++)
    for (j = i + 1; n - j + 1; j++) {
      cin >> a;
      if (a + 1) ans += a;
      if (a + 1) s[i] += a, s[j] += a, c[i]++, c[j]++;
    }
  if (k - 2)
    cout << 2 * ans / n;
  else {
    ans = 0;
    for (i = 1; i <= n; i++) ans += s[i] * (c[i] - 1);
    cout << 2 * ans / n / (n - 1) << endl;
  }
}
