#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  unsigned long long l, r, k, a, c, prev;
  cin >> l >> r >> k;
  a = 1;
  c = 0;
  while (a <= r) {
    if (a >= l) {
      if (c++ > 0) cout << " ";
      cout << a;
    }
    prev = a;
    a *= k;
    if (a / k != prev) break;
  }
  if (c == 0) cout << -1;
  cout << endl;
  return 0;
}
