def parse_problems(lines):
	""" Given a list of lines, parses them and returns a list of problems. """
	problems = []
	i = 0
	while i < len(lines):
		h, w = map(int, lines[i].split(" "))
		problems.append((w, h, lines[i + 1:i + h + 1]))
		i += h + 1
	return problems