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.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;

import javax.swing.text.InternationalFormatter;

import java.math.*;

import org.omg.CORBA.Any;

public class template {

	static long time = 0, mp = Integer.MAX_VALUE, k = 0, cnt = 0, edge = 0, no = 0,a=0, b=0;

	static int[] danger;
	static int[] init;
	static int[] col;
	static char[][] g;
	static String sb = "";
//	static ArrayList<Integer>[] a;
	static HashSet<Integer> []c;

	static ArrayList<Integer> p = new ArrayList<>();

	public static void main(String[] args) throws IOException {

		Reader scn = new Reader();

		int n = scn.nextInt();
		a=scn.nextLong(); b=scn.nextLong();
		
		int []a=scn.nextIntArray(n);
		
		
		for(int i:a){
			
			System.out.print(i-tokenused(i)+" ");
		}

		  
	}

	
	



	private static long tokenused(int n) {
		
		long paisa=(long)Math.floor(n*a/b);
		long tu=n;
		
		long lo=0, hi=n;
		
		while(lo<=hi){
			 long mid=(lo+hi)/2;
			 
			 if((long)Math.floor(mid*a/b) == paisa){
				 tu=mid;
				 hi=mid-1;
			 }
			 
			 else
				 lo=mid+1;
		}
		return tu;
	}




	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	// _________________________TEMPLATE_____________________________________________________________


	
	
	
	
	
	
	
	
	
	
	
//	static class comp implements Comparator<Integer> {
//
//		@Override
//		public int compare(Integer o1, Integer o2) {
//			return hm.get(o1) - hm.get(o2);
//		}
//
//	}
	static class pair implements Comparable<pair> {
		int n = 0;
		int cnt = 0;
		String s = "";
		// int cnt;

		pair(int b, int a, String k) {
			this.n = b;
			this.cnt = a;
			s = k;
			// cnt = x;
		}

		@Override
		public int compareTo(pair o) {

			return 1;

		}
	}

	// -----------PrintWriter for faster output---------------------------------
	public static PrintWriter out;

	public static class Reader {
		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine() throws IOException {
			byte[] buf = new byte[100000 + 1]; // line length
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.') {
				while ((c = read()) >= '0' && c <= '9') {
					ret += (c - '0') / (div *= 10);
				}
			}

			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}

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

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

		public int[][] nextInt2DArray(int m, int n) throws IOException {
			int[][] arr = new int[m][n];
			for (int i = 0; i < m; i++) {
				for (int j = 0; j < n; j++)
					arr[i][j] = nextInt();
			}
			return arr;
		}

	}

	// private static void rem(HashMap<Integer, Integer> hm) {
	//
	// Iterator<Map.Entry<Integer, Integer>> itr = hm.entrySet().iterator();
	// ArrayList<Integer> p=new ArrayList<>();
	//
	//
	// while(itr.hasNext()){
	// Map.Entry<Integer, Integer> entry = itr.next();
	// p.add(entry.getKey());
	//
	// }
	//
	//
	// for(int i:p){
	//
	// if(hm.get(i)>1)
	// hm.put(i, hm.get(i)-1);
	// else
	// hm.remove(i);
	// }
	// }

}
