You have received data from a Bubble bot. You know your task is to make factory facilities, but before you even start, you need to know how big the factory is and how many rooms it has. When you look at the data you see that you have the dimensions of the construction, which is in rectangle shape: N x M. 

Then in the next N lines you have M numbers. These numbers represent factory tiles and they can go from 0 to 15. Each of these numbers should be looked in its binary form. Because from each number you know on which side the tile has walls. For example number 10 in it's binary form is 1010, which means that it has a wall from the North side, it doesn't have a wall from the East, it has a wall on the South side and it doesn't have a wall on the West side. So it goes North, East, South, West. 

It is guaranteed that the construction always has walls on it's edges. The input will be correct. 

Your task is to print the size of the rooms from biggest to smallest. 

Input

The first line has two numbers which are N and M, the size of the construction. Both are integers: 

n (1 ≤ n ≤ 10^3)

m (1 ≤ m ≤ 10^3)

Next N x M numbers represent each tile of construction.

Output

Once you finish processing the data your output consists of one line sorted from biggest to smallest room sizes. 

Example

Input


4 5
9 14 11 12 13
5 15 11 6 7
5 9 14 9 14
3 2 14 3 14


Output


9 4 4 2 1 
6 1
13
5
7
15
13
7

3 2 1 



def main():
	n, m = map(int, input().split())
	grid = [list(map(int, input().split())) for _ in range(n)]
	visited = [[False] * m for _ in range(n)]
	rooms = []

	for i in range(n):
		for j in range(m):
			if visited[i][j]: continue
			room_size = 0
			stack = [(i, j)]
			while stack:
				x, y = stack.pop()
				if visited[x][y]: continue
				visited[x][y] = True
				room_size += 1
				# up 
				if x > 0 and not (grid[x][y] & 8 or grid[x-1][y] & 2):
					stack.append((x-1 , y))
				# right
				if y < m and not (grid[x][y] & 4 or grid[x][y+1] & 1):
					stack.append((x, y+1))
				# down
				if x < n and not (grid[x][y] & 2 or grid[x+1][y] & 8):
					stack.append((x+1, y))
				# left
				if y > 0 and not (grid[x][y] & 1 or grid[x][y-1] & 4):
					stack.append((x, y-1))

			rooms.append(room_size)

	rooms.sort(reverse=True) 

	print(' '.join(map(str, rooms)))




	

if __name__ == '__main__':
	main()