Bimokh is Mashmokh's boss. For the following n days he decided to pay to his workers in a new way. At the beginning of each day he will give each worker a certain amount of tokens. Then at the end of each day each worker can give some of his tokens back to get a certain amount of money. The worker can save the rest of tokens but he can't use it in any other day to get more money. If a worker gives back w tokens then he'll get <image> dollars. 

Mashmokh likes the tokens however he likes money more. That's why he wants to save as many tokens as possible so that the amount of money he gets is maximal possible each day. He has n numbers x1, x2, ..., xn. Number xi is the number of tokens given to each worker on the i-th day. Help him calculate for each of n days the number of tokens he can save.

Input

The first line of input contains three space-separated integers n, a, b (1 ≤ n ≤ 105; 1 ≤ a, b ≤ 109). The second line of input contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 109).

Output

Output n space-separated integers. The i-th of them is the number of tokens Mashmokh can save on the i-th day.

Examples

Input

5 1 4
12 6 11 9 1


Output

0 2 3 1 1 

Input

3 1 2
1 2 3


Output

1 0 1 

Input

1 1 1
1


Output

0 
import java.awt.geom.Line2D;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StreamCorruptedException;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.Stack;
import java.util.TreeSet;


public class Solution1 
{
    public static void main(String[] args) {
        //      FasterScanner in=new FasterScanner();
        //      PrintWriter out=new PrintWriter(System.out);
        //      int t=in.nextInt();
        //      for(int ii=0;ii<t;ii++)
        //      {
        new Solution1().solve();
        //      }//System.out.println(Long.MIN_VALUE);
        //      out.close();
        //System.out.println(func("anand patel","abjh"));
    }
    public Solution1()
    {
        in=new FasterScanner();
        out=new PrintWriter(System.out);
    }

    public Solution1(FasterScanner in,PrintWriter out)
    {
        this.in=in;
        this.out=out;
    }

    FasterScanner in;
    PrintWriter out;
    //  segmentTree t;
    //  segmentTree c;
    //  long mod=1000000007L ;
    //  long[] arr;
    //  Hashtable<Long, Integer> table;
    //  int d;
    //  int[] count;
    //  int n;
    public void solve()
    {
        int n=in.nextInt();
        long a=in.nextInt();
        long b=in.nextInt();
        long[] arr=in.nextLongArray(n);
        for(int i=0;i<n;i++)
        {
            long xx=(arr[i]*a)/b;
            long x=(long)Math.ceil((xx*b)/(a+0.0));
            out.print((arr[i]-x)+" ");
        }
        out.close();
    }

  
    
    public class ss implements Comparable<ss>
    {
        
        long w;
        int r;
        public ss(long w,int r)
        {
            
            this.w=w;
            this.r=r;
        }
        @Override
        public int compareTo(ss o) {
            // TODO Auto-generated method stub
            if(this.w!=o.w)
            {
                return Long.compare(this.w, o.w);
            }

            return 0;
        }

    }


    //source http://codeforces.com/blog/entry/18051
    class segmentTree
    {
        int n;  // array size
        long t[];

        public segmentTree(long[] arr)
        {
            n=arr.length;
            t=new long[3*n];
            for(int i=0;i<n;i++)
            {
                t[n+i]=arr[i];
            }
            build();
        }

        public void print()
        {
            for(int i=n;i<=n+15;i++)
            {
                out.print(t[i]+" ");
            }
            out.println();
        }

        void build() {  // build the tree
            for (int i = n - 1; i > 0; --i) t[i] = Math.max(t[i<<1] , t[i<<1|1]);
        }

        void modify(int p, long value) {  // set value at position p
            for (t[p += n] = value; p > 1; p >>= 1) t[p>>1] = Math.max(t[p] , t[p^1]);
        }

        long query(int l, int r) {  // sum on interval [l, r)
            long res = 0;
            for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
                if ((l&1)!=0) res = Math.max(res,t[l++]);
                if ((r&1)!=0) res = Math.max(t[--r],res);
            }
            return res;
        }
    }

    public class Node
    {
        int start;
        int stop;
        int val;
        Node left;
        Node right;

        int lazy;

        public Node(int start,int stop,int[] arr)
        {
            this.start=start;
            this.stop=stop;
            if(this.start==this.stop)
            {
                //TODO
                this.val=arr[start];
            }
            else
            {
                left=new Node(start,(start+stop)/2,arr);
                right=new Node((start+stop)/2+1,stop,arr);
                //TODO
                this.val=left.val+right.val;
            }
        }

        //      public void update(int idx,int v)
        //      {
        //          if(this.start==this.stop)
        //          {
        //              if(this.start==idx)
        //              {
        //                  this.val+=v;
        //              }
        //          }
        //          else
        //          {
        //              if(this.start<=idx && this.stop>=idx)
        //              {
        //                  left.update(idx, v);
        //                  right.update(idx, v);
        //                  this.val=left.val+right.val;
        //              }
        //          }
        //      }

        public int lazyUpdate(int l,int r)
        {
            if(l>r)
            {
                return 0;
            }
            if(this.start==this.stop)
            {
                if(l<=this.start && this.start<=r)
                {
                    this.val^=1;
                    return this.val;
                }
                else
                {
                    return this.val;
                }
            }
            else if(this.start>r || this.stop<l)
            {
                return this.val;
            }
            else if(this.start>=l && this.stop<=r)
            {
                this.lazy=1-this.lazy;
                this.val=this.stop-this.start+1-this.val;
                return this.val;
            }
            else
            {
                if(this.lazy==0)
                {
                    //left.query(l, r)+right.query(l, r);
                    this.val=left.lazyUpdate(l, r);
                    this.val+=right.lazyUpdate(l, r);
                }
                else
                {
                    this.lazy=0;
                    left.lazyUpdate(start,stop);
                    right.lazyUpdate(start, stop);
                    this.val=left.lazyUpdate(l, r);
                    this.val+=right.lazyUpdate(l, r);
                }
                return this.val;
            }
        }

        public int query(int l,int r)
        {
            if(l>r)
            {
                return 0;
            }
            if(this.start==this.stop)
            {
                if(l<=this.start && this.start<=r)
                {
                    return this.val;
                }
                else
                {
                    return 0;
                }
            }
            else if(this.start>r || this.stop<l)
            {
                return 0;
            }
            else if(this.start>=l && this.stop<=r)
            {
                return this.val;
            }
            else
            {
                if(this.lazy==0)
                {
                    return left.query(l, r)+right.query(l, r);
                }
                else
                {
                    this.lazy=0;
                    this.val=left.lazyUpdate(start,stop);
                    this.val+=right.lazyUpdate(start, stop);
                    return left.query(l, r)+right.query(l, r);
                }
            }
        }
    }


    public class UF {

        private int[] parent;  // parent[i] = parent of i
        private byte[] rank;   // rank[i] = rank of subtree rooted at i (never more than 31)
        private int count;   
        int[] seg;
        int max;
        // number of components
        public UF(int N) {
            if (N < 0) throw new IllegalArgumentException();
            count = N;
            parent = new int[N];
            rank = new byte[N];
            seg=new int[N];
            for (int i = 0; i < N; i++) {
                parent[i] = i;
                rank[i] = 0;
                seg[i]=1;
            }
            max=1;
        }

        public int find(int p) {
            if (p < 0 || p >= parent.length) throw new IndexOutOfBoundsException();
            while (p != parent[p]) {
                parent[p] = parent[parent[p]];    // path compression by halving
                p = parent[p];
            }
            return p;
        }

        public int count() {
            return count;
        }

        public boolean connected(int p, int q) {
            return find(p) == find(q);
        }

        public boolean union(int p, int q) {
            //  System.out.println("uf "+p+" "+q);
            int rootP = find(p);
            int rootQ = find(q);
            if (rootP == rootQ) return false;

            // make root of smaller rank point to root of larger rank
            if      (rank[rootP] < rank[rootQ])
            {
                parent[rootP] = rootQ;
                seg[rootQ]+=seg[rootP];
                max=Math.max(seg[rootQ],max);
            }
            else if (rank[rootP] > rank[rootQ])
            {
                parent[rootQ] = rootP;
                seg[rootP]+=seg[rootQ];
                max=Math.max(seg[rootP],max);
            }
            else {
                parent[rootQ] = rootP;
                rank[rootP]++;
                seg[rootP]+=seg[rootQ];
                max=Math.max(seg[rootP],max);
            }
            count--;
            return true;
        }

    }



    long pow(long a,int n,long m)
    {
        if(n==1)
            return a;
        if(n==0)
            return 1;
        long ans=pow(a,n/2,m);
        ans*=ans;
        ans%=m;
        if(n%2!=0)
            ans*=a;
        ans%=m;
        return ans;
    }

    public static int gcd(long a, long b) {
        BigInteger b1 = BigInteger.valueOf(a);
        BigInteger b2 = BigInteger.valueOf(b);
        BigInteger gcd = b1.gcd(b2);
        return gcd.intValue();
    }




    public static class FasterScanner {
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = System.in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public String nextString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

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

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

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

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
    }
} 