import java.util.*;
import java.io.*;

public class avl {
	
	public static void main(String[] args) throws Exception {
		
		Scanner fin = new Scanner(new File("avl.in"));
		
		int n = Integer.parseInt(fin.nextLine().trim());	
		
		for (int i=0; i<n; i++) {
			
			String line = fin.nextLine();
			
			StringTokenizer tok = new StringTokenizer(line);
			
			int numNodes = tok.countTokens();
			
			int[] nodes = new int[numNodes];
			
			for (int j=0; j<numNodes; j++)
				nodes[j] = Integer.parseInt(tok.nextToken());
				
			if (validAVL(nodes))
				System.out.println("yes");
			else
				System.out.println("no");
		}	
		
		fin.close();
	}
	
	
	public static boolean validAVL(int[] nodes) {
		
		// We assume that nodes[0] = 1 based on spec.
		int indexToCheck = 1;
		
		// There's no need to check the last node, since no imbalance could
		// ever happen there.
		while (indexToCheck < nodes.length-1) {
			
			// Both a left and right child exists here.
			if (nodes[indexToCheck]/2 == nodes[indexToCheck+1]/2) {
			
				int left = height(nodes, indexToCheck);
				int right = height(nodes, indexToCheck+1);
				
				// Their heights differ by too much.
				if (Math.abs(left-right) > 1)
					return false;
					
				// We advance past both of these nodes.
				indexToCheck += 2;
			}
			
			// No child in the other direction and a node below this one
			// means no AVL tree.
			else if (height(nodes, indexToCheck) > 0) 
				return false;
			
			// We only had one child to check, so let's advance one spot.
			else
					indexToCheck++;
			
		}
		
		return true;
	}
	
	public static int height(int[] nodes, int index) {
		
		// Stores height of tree.
		int h = 0;
		
		// Stores the low and high bounds of descendants of the node stored
		// in index.
		long low = 2*nodes[index];
		long high = 2*nodes[index]+1;
		int curh = 1;
		
		// Loop through all nodes.
		while (low <= nodes[nodes.length-1]) {
			
			// This means we've found a node in this subtree that is of
			// distance curh from the root node stored in index.
			if (binSearch(nodes, low, high))
				h = curh;
		
			// Set low and high to search on the next level.
			low = 2*low;
			high = 2*high+1;
			curh++;
		}
		
		return h;
	}
	
	public static boolean binSearch(int[] nodes, long low, long high) {
		
		int lowIndex = 0;
		int highIndex = nodes.length-1;
		while (lowIndex <= highIndex) {
			int midIndex = (lowIndex+highIndex)/2;
			if (nodes[midIndex] >= low && nodes[midIndex] <= high)
				return true;
			else if (nodes[midIndex] < low)
				lowIndex = midIndex + 1;
			else
				highIndex = midIndex - 1;
		}
		return false;
	}
}