#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
long long l, r, k;
bool ok = 0;
int main() {
  cin >> l >> r >> k;
  long long x = 1;
  while (x <= r) {
    if (x >= l && x <= r) {
      ok = 1;
      cout << x << " ";
    }
    if ((long long)1e18 / x < k) break;
    x *= k;
  }
  if (!ok) puts("-1");
  return 0;
}
