Graph: . Cycle: . Tail: . Cycle length is , tail node is distance from cycle. Query : both in cycle. Indices: at , at . Distance: .
From node , go steps to reach node . Query : in tail (distance to cycle at node , index ). Jump to cycle, then . Total: .