#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l, r, k, x = 1, yx;
  cin >> l >> r >> k;
  int fg = 0;
  yx = (r / k);
  while (x <= r) {
    if (x >= l) {
      cout << x;
      cout << " ";
      fg = 1;
    }
    if (x > yx) break;
    x = x * k;
  }
  if (fg == 0) printf("-1");
  return 0;
}
