Graph: f(1)=2,f(2)=3,f(3)=1,f(4)=2. Cycle: 1→2→3→1. Tail: 4. Cycle length is 3, tail node 4 is distance 1 from cycle. Query (1,3): both in cycle. Indices: 1 at 0, 3 at 2. Distance: (2−0)mod3=2.
From node 1, go 2 steps to reach node 3. Query (4,3): 4 in tail (distance 1 to cycle at node 2, index 1). Jump to cycle, then (2−1)mod3=1. Total: 1+1=2.