列出我无法弄清楚的Python问题

我有10个不同的列表,它们的数字从0到10。这10个列表中的每个都是“人”,它们包含的数字是“朋友”。数字是它们的ID。所以我有这样的事情:

person = 0   friend = 5
person = 1   friend = 2
person = 1   friend = 3
person = 1   friend = 4
person = 1   friend = 6
person = 1   friend = 8
person = 2   friend = 1
person = 2   friend = 4
person = 2   friend = 6
person = 2   friend = 7
person = 2   friend = 9
person = 3   friend = 1
person = 3   friend = 6
person = 3   friend = 8
person = 4   friend = 1
person = 4   friend = 2
person = 4   friend = 6
person = 4   friend = 7
person = 4   friend = 9
person = 5   friend = 0
person = 6   friend = 1
person = 6   friend = 2
person = 6   friend = 3
person = 6   friend = 4
person = 6   friend = 8
person = 7   friend = 2
person = 7   friend = 4
person = 7   friend = 9
person = 8   friend = 1
person = 8   friend = 3
person = 8   friend = 6
person = 9   friend = 2
person = 9   friend = 4
person = 9   friend = 7

现在我想找到一个人的朋友的朋友。我的意思是我想要这样的输出。

人0与5相关

人1与2、3、4、6、8以及这些朋友的朋友有关。所以输出必须是这样的:

人1与2(4、6、7、9),3(6、8),4(2、6、7、9),6(2、3、4、8),8(3、6)相关)。还有朋友的朋友的朋友,例如:

人1与2(4(2,6,7,9),6(1,3,4,8).........相关

然后,我将从列表中删除重复的数字,这样我将得到以下内容:

人1与2、3、4、6、7、8、9有关。因为人1与所有这些人都有关系,甚至是间接的。我不确定我是否能够解释自己,但您可以问我不清楚的观点。谢谢你的时间。