detecting and printing negative cycles