class m2(list):
	#very simple 2d matrix for map making

	def __init__(self,w,h,fill=None):	#choose ure width and heitgh
		self.w, self.h = w, h
		for x in range(w*h):
			self.append(fill)
			
	def offset(self,x,y):
		if x > self.w or y > self.h:
			return -1
		return (x + (y*self.w))

	def at(self,x,y,fill=None):
		if x > self.w or y > self.h:
			return -1
		if fill != None:
			self[self.offset(x,y)] = fill
		return self[self.offset(x,y)]
		
	def where(self,fill):
		tmp = self.index(fill)
		return (tmp % self.w, tmp / self.w)
		
	def get_line(self,y,fills=[]):
		tmp = []
		if len(fills) > 0 and len(fills) != self.w:
			return -1
		for x in range(self.w):
			if len(fills) == self.w:
				self.at(x,y,fills[x])
			tmp.append( self.at(x,y))
		return tmp
		
	def get_col(self,x,fills=[]):
		tmp = []
		if len(fills) > 0 and len(fills) != self.h:
			return -1
		for y in range(self.h):
			if len(fills) == self.h:
				self.at(x,y,fills[y])
			tmp.append(self.at(x,y))
		return tmp
		
