Problem: Programmer Rostislav got seriously interested in the Link/Cut Tree data structure, which is based on Splay trees. Specifically, he is now studying the expose procedure.

Unfortunately, Rostislav is unable to understand the definition of this procedure, so he decided to ask programmer Serezha to help him. Serezha agreed to help if Rostislav solves a simple task (and if he doesn't, then why would he need Splay trees anyway?)

Given integers l, r and k, you need to print all powers of number k within range from l to r inclusive. However, Rostislav doesn't want to spent time doing this, as he got interested in playing a network game called Agar with Gleb. Help him!

Input

The first line of the input contains three space-separated integers l, r and k (1 ≤ l ≤ r ≤ 1018, 2 ≤ k ≤ 109).

Output

Print all powers of number k, that lie within range from l to r in the increasing order. If there are no such numbers, print "-1" (without the quotes).

Examples

Input

1 10 2


Output

1 2 4 8 

Input

2 4 5


Output

-1

Note

Note to the first sample: numbers 20 = 1, 21 = 2, 22 = 4, 23 = 8 lie within the specified range. The number 24 = 16 is greater then 10, thus it shouldn't be printed.

Solution (in JAVA):

Solution:
import java.io.*;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.InputMismatchException;

import static java.lang.StrictMath.*;


public class Main extends IOException {
    public static void main(String[] args) throws IOException {
        InputStream inputStream =  System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskA solver = new TaskA();
        //int testCount = Integer.parseInt(in.next());
        //for (int i = 1; i <= testCount; i++)
        //solver.solve(i, in, out);
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskB {
    private static final StringBuilder builder = new StringBuilder();
    private static final int MOD = (int)1e+9 + 7;
    private static final String YES = "YES";
    private static final String Yes = "Yes";
    private static final String NO = "NO";
    private static final String No = "No";
    private static final String EMPTY = "";
    private static final char SPACE = ' ';
    private static final char ENDL  = '\n';

    public void solve(int testNumber, FastScanner in, FastPrinter out) {
        int n = in.nextInt();
        int A = in.nextInt();
        int cf = in.nextInt();
        int cm = in.nextInt();
        int m = in.nextInt();
        Integer[] a = new Integer[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
    }

}
class TaskA {
    private static final StringBuilder builder = new StringBuilder();
    private static final int MOD = (int)1e+9 + 7;
    private static final String YES = "YES";
    private static final String Yes = "Yes";
    private static final String NO = "NO";
    private static final String No = "No";
    private static final String EMPTY = "";
    private static final char SPACE = ' ';
    private static final char ENDL  = '\n';

    public void solve(int testNumber, FastScanner in, FastPrinter out) {
        BigInteger l = new BigInteger(in.next());
        BigInteger r = new BigInteger(in.next());
        BigInteger k = new BigInteger(in.next());
        BigInteger p = BigInteger.ONE;
        boolean ok = false;
        while (p.compareTo(r) != 1){
            if (p.compareTo(l) != -1 && p.compareTo(r)!= 1){
                builder.append(p).append(' ');
                ok = true;
            }
            p = p.multiply(k);
        }
        if (!ok){
            builder.append("-1");
        }
        out.print(builder.toString());
    }
}
class TaskD {
    private static final StringBuilder builder = new StringBuilder();
    private static final int MOD = (int)1e+9 + 7;
    private static final String YES = "YES";
    private static final String Yes = "Yes";
    private static final String NO = "NO";
    private static final String No = "No";
    private static final String EMPTY = "";
    private static final char SPACE = ' ';
    private static final char ENDL  = '\n';

    public void solve(int testNumber, FastScanner in, FastPrinter out) {
        int n = in.nextInt();
        double rmin = 1e+9, rmax = -1;
        double x = in.nextInt();
        double y = in.nextInt();
        for (int i = 0; i < n; i++) {
            double tx = in.nextInt();
            double ty = in.nextInt();
            double dist = sqrt((x - tx) * (x - tx) + (y - ty) * (y - ty));
            if (dist > rmax){
                rmax = dist;
            }
            if (dist < rmin){
                rmin = dist;
            }
        }
        double ans = PI * (rmax * rmax - rmin*rmin);
        out.print(ans);
    }

    private int check(String s){
        if (s.charAt(0) != '1'){
            return -1;
        }
        int count = 0;
        for (int i = 1; i < s.length() ; i++) {
            if (s.charAt(i) == '0') count++;
        }
        if (count != s.length() - 1){
            return -1;
        }
        return count;
    }
}
class Vector{
    double x, y, z;

    public Vector(double x, double y, double z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    public double abs(){
        return Math.sqrt(x * x + y * y + z * z);
    }

    public double skalyarMultyply(Vector other){
        return (x * other.x + y * other.y + z * other.z);
    }

    public Vector vectorMultyply(Vector other){
        double i = y * other.z - z * other.y;
        double j = z * other.x - x * other.z;
        double k = x * other.y - y * other.x;
        return new Vector(i, j, k);
    }

    public double mixMultylpy(Vector b, Vector c){
        return this.skalyarMultyply(b.vectorMultyply(c));
    }
}
class FastScanner extends BufferedReader {
    boolean isEOF;

    public FastScanner(InputStream is) {
        super(new InputStreamReader(is));
    }

    public FastScanner(InputStreamReader inputStreamReader) {
        super(inputStreamReader);
    }

    public int read() {
        try {
            int ret = super.read();
            if (isEOF && ret < 0) {
                throw new InputMismatchException();
            }
            isEOF = ret == -1;
            return ret;
        } catch (IOException e) {
            throw new InputMismatchException();
        }
    }

    public String next() {
        StringBuilder sb = new StringBuilder();
        int c = read();
        while (isWhiteSpace(c)) {
            c = read();
        }
        while (!isWhiteSpace(c)) {
            sb.appendCodePoint(c);
            c = read();
        }
        return sb.toString();
    }

    public static boolean isWhiteSpace(int c) {
        return c >= -1 && c <= 32;
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public int nextInt() {
        int c = read();
        while (isWhiteSpace(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int ret = 0;
        while (!isWhiteSpace(c)) {
            if (c < '0' || c > '9') {
                throw new NumberFormatException("digit expected " + (char) c
                        + " found");
            }
            ret = ret * 10 + c - '0';
            c = read();
        }
        return ret * sgn;
    }

    public double nextDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, nextInt());
            if (c < '0' || c > '9')
                throw new UnknownError();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new UnknownError();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }

    public long nextLong(){
        return Long.parseLong(next());
    }

    public int[] nextIntArray(int n){
        int[] ret = new int[n];
        for (int i = 0; i < n; i++) {
            ret[i] = nextInt();
        }
        return ret;
    }

    public long[] nextLongArray(int n) {
        long[] ret = new long[n];
        for (int i = 0; i < n; i++) {
            ret[i] = nextLong();
        }
        return ret;
    }
}

final class FastPrinter extends PrintWriter {
    public FastPrinter(OutputStream out) {
        super(out);
    }
}
class Pair<U, V> implements Comparable<Pair<U, V>> {
    public final U first;
    public final V second;

    public static<U, V> Pair<U, V> makePair(U first, V second) {
        return new Pair<U, V>(first, second);
    }

    private Pair(U first, V second) {
        this.first = first;
        this.second = second;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Pair pair = (Pair) o;

        return !(first != null ? !first.equals(pair.first) : pair.first != null) && !(second != null ? !second.equals(pair.second) : pair.second != null);

    }

    public int hashCode() {
        int result = first != null ? first.hashCode() : 0;
        result = 31 * result + (second != null ? second.hashCode() : 0);
        return result;
    }

    public String toString() {
        return "(" + first + "," + second + ")";
    }

    public int compareTo(Pair<U, V> o) {
        int value = ((Comparable<U>)first).compareTo(o.first);
        if (value != 0)
            return value;
        return ((Comparable<V>)second).compareTo(o.second);
    }
}