// Arup Guha
// 5/5/2015
// Solution to FHSPS Problem: Top of the Eye

import java.util.*;

public class eye {

	// Constants for this problem.
	final public static int ACC_GRAVITY = -32;
	final public static int CENTER_X = 0;
	final public static int CENTER_Y = 205;
	final public static int RADIUS = 200;
	final public static int DEG_PER_CIRCLE = 360;

	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 angular velocity, convert regular velocity.
			double angVel = stdin.nextDouble();
			double velocity = 2*Math.PI*RADIUS*angVel/DEG_PER_CIRCLE;

			// Read and convert location to radians.
			double startAngle = stdin.nextDouble()*2*Math.PI/DEG_PER_CIRCLE;

			// Get current position.
			double curX = CENTER_X+RADIUS*Math.cos(startAngle);
			double curY = CENTER_Y+RADIUS*Math.sin(startAngle);

			// Get current velocity vector.
			double dx = -velocity*Math.sin(startAngle);
			double dy = velocity*Math.cos(startAngle);

			// Solve for time when the penny hits the ground.
			double a = 16;
			double b = -dy;
			double c = -curY;

			// There is always guaranteed to be a root, since we start above ground and eventually fall.
			double timeHitGround = (-b + Math.sqrt(b*b-4*a*c))/(2*a);

			// Calculate what x coordinate the penny will have at this time and print it out.
			double newx = curX + timeHitGround*dx;

			// This is annoying - fixes the -0 case...
			if (Math.abs(newx) >= .5)
				System.out.printf("%.0f\n", newx);
			else
				System.out.printf("0\n");
		}
	}
}