@@ -0,0 +1,1638 @@
+package com.hackerearth.augustjam14;%0A%0Aimport java.io.*;%0Aimport java.util.StringTokenizer;%0A%0Aimport static java.lang.Integer.parseInt;%0Aimport static java.lang.System.in;%0Aimport static java.lang.System.out;%0A%0A/**%0A * Author : Suresh%0A * Date : 04/06/15.%0A */%0A%0A/**%0A * https://www.hackerearth.com/problem/algorithm/find-the-ring/%0A */%0Apublic class FindTheRing %7B%0A%0A    private static BufferedReader reader;%0A    private static StringTokenizer tokenizer;%0A%0A    private static String next() throws IOException %7B%0A        while (!tokenizer.hasMoreTokens()) %7B%0A            tokenizer = new StringTokenizer(%0A                    reader.readLine());%0A        %7D%0A        return tokenizer.nextToken();%0A    %7D%0A%0A    private static int nextInt() throws IOException %7B%0A        return parseInt(next());%0A    %7D%0A%0A    public static void main(String%5B%5D args) throws IOException %7B%0A        reader = new BufferedReader(new InputStreamReader(in));%0A        tokenizer = new StringTokenizer(%22%22);%0A        PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out)));%0A%0A        int T = nextInt();%0A        for (int t = 0; t %3C T; t++) %7B%0A            int index = nextInt();%0A            int N = nextInt();%0A%0A            if (N == 0) %7B%0A                pw.println(index);%0A            %7D else if (index == 0 %7C%7C index == 2) %7B%0A                if (N %25 2 == 0) %7B%0A                    pw.println(0);%0A                %7D else%0A                    pw.println(1);%0A%0A            %7D else %7B%0A                if (N %25 2 == 0) %7B%0A                    pw.println(1);%0A                %7D else%0A                    pw.println(0);%0A            %7D%0A        %7D%0A%0A%0A        reader.close();%0A        pw.close();%0A    %7D%0A%7D%0A

Find the ring