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

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

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

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

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

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

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

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

i.q = l
i.o = b
d.w = b
d.o = b
b.p = l
b.s = d
l.q = i
l.o = b
assert d.o.p.q.q.txt == "l"