#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l, r, k;
  cin >> l >> r >> k;
  int ok = 0;
  long long x = 1ll;
  while (x <= r) {
    if (x >= l) {
      ok++;
      cout << x << ' ';
    }
    if (r / k < x)
      break;
    else
      x = x * k;
  }
  if (ok == 0) cout << "-1";
  return 0;
}
