Examples
Input: (6, [(0, 1), (0, 2), (1, 3), (2, 3), (2, 4), (4, 5)], [('follows', 0, 1), ('followers', 3), ('followees', 2), ('recommend', 0, 3)])
Expected Output: [True, [1, 2], [3, 4], [3, 4]]
Explanation: 0 follows 1. Users 1 and 2 follow 3. User 2 follows 3 and 4. For recommendations from 0, the two-step candidates are 3 (through 1 and 2) and 4 (through 2), so 3 ranks above 4.
Input: (5, [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3), (1, 4), (2, 4), (2, 0)], [('recommend', 0, 5), ('follows', 2, 0), ('followers', 0), ('followees', 0)])
Expected Output: [[3, 4], True, [2], [1, 2]]
Explanation: For user 0, candidate 2 is reachable in two steps but is already directly followed, so it is excluded. Users 3 and 4 are each reached through both 1 and 2, and tie-break by smaller id gives [3, 4].
Input: (4, [], [('follows', 0, 1), ('followers', 2), ('followees', 3), ('recommend', 1, 2)])
Expected Output: [False, [], [], []]
Explanation: With no edges, nobody follows anyone and there are no second-degree recommendations.
Input: (6, [(0, 1), (0, 1), (0, 2), (1, 3), (1, 4), (2, 3), (2, 5), (2, 5), (4, 5)], [('followers', 1), ('recommend', 0, 1), ('recommend', 0, 3)])
Expected Output: [[0], [3], [3, 4, 5]]
Explanation: Duplicate edges are ignored. User 0 reaches 3 through both 1 and 2, while 4 and 5 are each reached once, so the ranking is 3 first, then 4 and 5 by user id.
Input: (3, [(0, 1), (1, 2)], [('recommend', 0, 0), ('recommend', 0, 5), ('follows', 0, 2)])
Expected Output: [[], [2], False]
Explanation: When k = 0, return an empty list. With a larger k, user 2 is the only valid two-step recommendation for user 0. User 0 does not directly follow 2.