// Arup Guha
// 5/5/2015
// Solution to FHSPS Problem: Dinner and a Movie

import java.util.*;

public class movie {

	// Constants for this problem.
	final public static int TICKET_PRICE = 10;
	final public static int TICKET_LIMIT = 10;
	final public static int CHEAP_PIZZA = 1;
	final public static int REG_PIZZA = 2;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process each case.
		for (int loop=0; loop<numCases; loop++) {

			// Read in what we're buying.
			int tickets = stdin.nextInt();
			int pizza = stdin.nextInt();

			// We must spend this.
			int total = TICKET_PRICE*tickets;

			// Get the discount on pizza.
			if (tickets >= TICKET_LIMIT)
				total += CHEAP_PIZZA*pizza;

			// Regular price.
			else
				total += REG_PIZZA*pizza;

			// Display the result.
			System.out.println(total);
		}
	}
}