#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l, r, k;
  long long num = 1;
  int flag = 0, flag2 = 0;
  cin >> r >> l >> k;
  while (num <= l) {
    if (num * k > l) flag = 1;
    if (num >= r && flag == 0) {
      cout << num << " ";
      flag2 = 1;
    }
    if (num >= r && flag == 1) {
      cout << num << endl;
      flag2 = 1;
    }
    if (num > l / k)
      break;
    else
      num *= k;
  }
  if (flag2 == 0) cout << -1 << endl;
  return 0;
}
