#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l, r, k;
  cin >> l >> r >> k;
  int count = 0;
  long long x = 1, y = 1;
  do {
    if (x >= l && x <= r) {
      if (count) cout << " ";
      cout << x;
      count++;
    }
    y = x;
    x *= k;
  } while (y <= r / k);
  if (!count) cout << -1;
  cout << "\n";
  return 0;
}
