#include <bits/stdc++.h>
using namespace std;
bool debug = false;
int n, k;
const int mx = 10000;
long long dp[105][mx];
const long long mod = 1e9 + 7;
const long long inv2 = 5e8 + 4;
long long qp(long long a, long long b) {
  if (b == 0) {
    return 1;
  }
  long long ans = qp(a, b / 2);
  if (b % 2) {
    return ans * ans % mod * a % mod;
  } else {
    return ans * ans % mod;
  }
}
int main(int argc, char* argv[]) {
  ios::sync_with_stdio(0);
  cin >> n >> k;
  dp[n + 1][0] = 1;
  for (int i = n; i >= 1; i--) {
    for (int j = 0; j < mx; j++) {
      for (int l = 0; l <= k; l++) {
        if (l <= i) {
          if (j + (l + j) / i < mx) {
            dp[i][j + (l + j) / i] += dp[i + 1][j];
            dp[i][j + (l + j) / i] %= mod;
          }
        } else {
          dp[i][j] += dp[i + 1][j];
          dp[i][j] %= mod;
        }
      }
    }
  }
  long long killed = 0;
  for (int i = 0; i < mx; i++) {
    killed += 1ll * i * dp[1][i] % mod;
    killed %= mod;
  }
  cout << killed << endl;
  long long tot =
      qp(k + 1, n - 1) * k % mod * (k + 1) % mod * inv2 % mod * n % mod;
  cout << tot << endl;
  cout << (tot - killed + mod) % mod << endl;
  return 0;
}
