Simple Permutation combination 
IntuitionApproachIf we fix two points then contribution of those two points will (nm - 2)C(k - 2)(distance between the two ponints). The reason is all other (k
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
If we fix two points then contribution of those two points will (n*m - 2)C(k - 2)*(distance between the two ponints). The reason is all other (k - 2) points have (n*m - 2) options
If we fix one and see its total contribution with all other points then, it's total contribution will be (n*m-2)C(k-2)*(sum of distance of all the points from this point)
Let us define cal(x) = x*(x+1)/2
Distance of all the points from x, y is = n*(cal(y - 1) + cal(m - y)) + m*(cal(x - 1) + cal(n - x))
Therefore, we calculate contribution of all the points in ans variable.
At last, we divide ans by 2 since every pair is calculated 2 times

# Complexity
- Time complexity:
O(n^2)
- Space complexity:
O(n*m)

# Code
```cpp []
class Solution {
public:
    const long long MOD = (long long)1e9 + 7;

    long long add(long long x, long long y) {
        return (((x) % MOD + (y) % MOD) % MOD + MOD) % MOD;
    }

    long long mul(long long x, long long y) { 
        return ((x % MOD) * 1ll * (y % MOD)) % MOD; 
    }

    long long binpow(long long x, long long y) {
        long long z = 1;
        while (y) {
            if (y % 2 == 1)
                z = mul(z, x);
            x = mul(x, x);
            y /= 2;
        }
        return z;
    }

    long long inv(long long x) { 
        return binpow(x, MOD - 2); 
    }

    long long divide(long long x, long long y) { 
        return mul(x, inv(y)); 
    }

    int distanceSum(int m, int n, int k) {
        long long M = n*m + 1;
        vector<long long> fac(M + 1, 1), invfac(M + 1, 0);
        for (long long i = 1; i <= M; ++i)
            fac[i] = mul(fac[i - 1], i);
        invfac[M] = inv(fac[M]);
        for (long long i = M - 1; i >= 0; --i)
            invfac[i] = mul(invfac[i + 1], i + 1);

        auto ncr = [&](long long n, long long r) {
            cout << n << "\n";
            assert(n < M);
            
            return mul(fac[n], mul(invfac[n - r], invfac[r]));
        };

        long long ans = 0;
        long long val = ncr(n * m - 2ll, k - 2ll);
        auto cal = [&](long long x)
        {
            return max(0ll,(x*(x+1ll))/2ll);
        };
        for (long long i = 1; i <= n; ++i) {
            for (long long j = 1; j <= m; ++j) {
                long long dist = 0;
            dist = add(mul(n, add(cal(j - 1), cal(m - j))), mul(m, add(cal(i - 1ll), cal(n - i))));
                ans = add(ans, mul(val, dist));
            }
        }
        return divide(ans, 2ll);
    }
};
```
['Math', 'C++']