https://www.acmicpc.net/problem/1012 for(int c =0; c 0){ st = new StringTokenizer(br.readLine()); int X = Integer.parseInt(st.nextToken()); int Y = Integer.parseInt(st.nextToken()); input[X][Y]=1; } for(int i=0;i q = new LinkedList(); q.add(new Pair(i,j)); while..