import java.io.*;
import java.util.*;

public class Problem1 {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner ( new FileReader ("DATA1.txt") ) ;
		PrintWriter pw = new PrintWriter ( new FileWriter ( "OUT1.txt" ) );
		
		for ( int i = 0; i < 5; i++ ) {
			int n = Integer.parseInt(sc.next().trim());
			int c = Integer.parseInt(sc.next().trim());
			n = n>>c;
			
			if ( n % 2 == 0 ){
				pw.println("0");
			}else{
				pw.println("1");
			}
			pw.flush();
		}
		
		pw.close();
		sc.close();
	}

}

