#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const int MAX = 1e5 + 10;
const int MOD = 1000000007;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long int a, b, c;
  cin >> a >> b >> c;
  long long int start = 1, limit = pow(10, 18);
  int flag = 1;
  while (start <= b) {
    if (start >= a) {
      flag = 0;
      cout << start << " ";
    }
    if (((start * c) / c) != start)
      break;
    else
      start *= c;
  }
  if (flag) cout << -1;
  return 0;
}
