#include <bits/stdc++.h>
using namespace std;
long long a[10000001];
int main() {
  long long l, r, k, i, o = 0;
  cin >> l >> r >> k;
  i = 1;
  while (i <= r) {
    if ((i >= l) && (i <= r)) {
      cout << i << " ";
      o++;
    }
    if (r / k >= i)
      i *= k;
    else
      i = r + 1;
  }
  if (o == 0) cout << -1 << endl;
  return 0;
}
