#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  unsigned long long l, r, k;
  cin >> l >> r >> k;
  unsigned long long c = 1;
  int flag = 0;
  if (l == 1) {
    flag = 1;
    cout << c << " ";
  }
  while (c <= r) {
    if (c >= l && c % k == 0) {
      flag = 1;
      cout << c << " ";
    }
    c = c * k;
  }
  if (flag == 0) cout << "-1";
  cout << "\n";
}
