fixed error by writeing to stdin instead of stdout
fixed error by writeing to stdin instead of stdout
fixed hard error (the start point was not in the rbtree so an cycle where posible)