#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l, r, n, m = 1;
  int f = 0;
  cin >> l >> r >> n;
  while (m <= r) {
    if (m >= l) f = 1, cout << m << ' ';
    if (m <= r / n)
      m *= n;
    else
      break;
  }
  if (!f) cout << "-1" << endl;
  return 0;
}
