class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: C = None
        self.o: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.y: B = None
        self.txt = txt

i = A("i")
l = B("l")
b = C("b")

i.p = b
l.y = b
l.p = b
l.o = i
b.s = i
b.y = l
assert l.p.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: C = None
        self.o: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.y: B = None
        self.txt = txt

i = A("i")
l = B("l")
b = C("b")

i.p = b
l.y = b
l.p = b
l.o = i
b.s = i
b.y = l
assert l.p.y.y.txt == "b"