// Arup Guha
// 2/2/2014
// Solution to 2014 UCF HS Online Contest Problem: LTE (ha ha...)

import java.util.*;

public class robot {

	public final static double EPSILON = 0.000000001;
	public final static double RAD_PER_DEGREE = Math.PI/180;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process each case.
		for (int loop=1; loop<=numCases; loop++) {

			int n = stdin.nextInt();
			double endX = stdin.nextDouble();
			double endY = stdin.nextDouble();

			double curX = 0, curY = 0, curAngle = 0;

			// Simulate each step.
			for (int i=0; i<n; i++) {

				// Update next angle and distance.
				curAngle -= (stdin.nextDouble()*RAD_PER_DEGREE);
				double dist = stdin.nextDouble();

				// Move...using cos and sin.
				curX += dist*Math.cos(curAngle);
				curY += dist*Math.sin(curAngle);
			}

			double dist = Math.sqrt(Math.pow(curX-endX,2)+Math.pow(curY-endY,2));

			// Print the output appropriately. Note: For input spec EPSILON isn't necessary.
			if (Math.abs(dist) <= 1+EPSILON)
				System.out.println("Trip #"+loop+": YES");
			else
				System.out.println("Trip #"+loop+": NO");
		}
	}
}