public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		StringBuilder out = new StringBuilder();
		precal();
		while ((line = in.readLine()) != null && line.length() != 0) {
			int ntest = Integer.parseInt(line.trim()), i, d, v[];
			if (ntest == -1)
				break;
			for (int t = 0; t < ntest; t++) {
				v = retInts(in.readLine());
				d = v[0];
				i = v[1];
				v[0] = a[i];
				for (int j = 0; j < 20 - d; j++)
					v[0] = v[0] / 2;
				out.append(v[0] + "\n");
			}
		}
		System.out.print(out);
	}