I was asked below question in google interview but could not answer it. I did google search but could not find any correct solution for this problem. Can you please help me to provide a solution for this problem?
Design a data structure to support following functions:
- setManager(A, B) sets A as a direct manager of B
- setPeer(A, B) sets A as a colleague of B. After that, A and B will have the same direct Manager.
- query(A, B) returns if A is in the management chain of B. Every person only has 1 direct manager.

Use three hash tables 1. employee to group id mapping (emp) 2. group id to list of employees (gid) 3. group id -> manager id table (manager)