#include <bits/stdc++.h>
using namespace std;
long long l, r, k, x;
int main() {
  cin >> l >> r >> k;
  bool notFirst = false;
  long long lastX = 1;
  x = 1;
  long long lim = 1000000000000000000;
  while (x <= r && x > 0 && x <= lim) {
    if (lastX > x) break;
    if (x >= l) {
      if (notFirst)
        printf(" ");
      else
        notFirst = 1;
      cout << x;
    }
    lastX = x;
    x *= k;
    if (x / k != lastX) break;
  }
  if (!notFirst)
    puts("-1");
  else
    puts("");
  return 0;
}
