/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Main { private static final int[] dx = { 0, 1, 0, -1}; private static final int[] dy = {-1, 0, 1, 0}; public static void main (String[] args) throws java.lang.Exception { // your code goes here BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] lines = br.readLine().split(" "); int H = Integer.parseInt(lines[0]); int W = Integer.parseInt(lines[1]); int[][] map = new int[H][W]; for(int i=0;i stack = new Stack(); stack.push(new Pair(h,w)); while(!stack.isEmpty()){ Pair now = stack.pop(); try{ if(map[now.h][now.w] != color){ map[now.h][now.w] = color; for(int i=0;i<4;i++){ stack.push(new Pair(now.h+dx[i],now.w+dy[i])); } } }catch(Exception e){} } } private static class Pair{ public int h; public int w; public Pair(int h,int w){ this.h = h; this.w = w; } } }