text: min(upper, lower); } private static int getValue(int x, int y, char[][] matrix) { // y / 4 th bit // y % 4 th bit from left int bit = getValue(matrix[x][y / 4]); int mask = (3 - (y % 4)); return (bit >> mask) & 1; } private static int getValue(char hexChar) { int bit; if (Character.isAlphabetic(hexChar)) { bit = (hexChar - 'A') + 10; } else { bit = hexChar - '0'; } return bit; } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public int nextInt() { return Integer.parseInt(next()); } } }