code: def solve(succ, orien, i, direc):
      
      assert orien[i] is not None
      j = succ[i][direc]
      if j is None:          # basic case
          return False
      if j == len(orien) - 1:
          return True
      if orien[j] is None:   # try both orientations
          for x in [0, 1]:
              orien[j] = x
              if solve(succ, orien, j, reflex[direc][x]):
                  return True
          orien[j] = None
          return False
      else:
          return solve(succ, orien, j, reflex[direc][orien[j]])
docs: Can a laser leaving mirror i in direction direc reach exit ?
  
      :param i: mirror index
      :param direc: direction leaving mirror i
      :param orient: orient[i]=orientation of mirror i
      :param succ: succ[i][direc]=succ mirror reached
                   when leaving i in direction direc