def canbereached(R,C,cell,left,right,up,down,grid): res=set([cell]) tmp={} while len(tmp)