// Arup Guha
// 8/30/2017
// Solution to 2017 UCF Locals Problem: Electric Bill

import java.util.*;

public class energy {

	final public static int CUTOFF = 1000;

	public static void main(String[] args) {

		// Get the usage rates.
		Scanner stdin = new Scanner(System.in);
		int initR = stdin.nextInt();
		int extraR = stdin.nextInt();

		// Process all the bills.
		int n = stdin.nextInt();
		for (int loop=0; loop<n; loop++) {

			// First add the initial cost.
			int kw = stdin.nextInt();
			int cost = Math.min(CUTOFF, kw)*initR;

			// Payment for extra eletricity use.
			if (kw > CUTOFF) cost += (kw-CUTOFF)*extraR;

			// Ta da!
			System.out.println(kw+" "+cost);
		}
	}
}