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

class B:
    def __init__(self, txt: str):
        self.q: B = None
        self.u: C = None
        self.z: B = None
        self.txt = txt

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

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

m.o = b
a.q = i
a.z = i
a.u = b
b.w = m
l.o = b
i.q = a
i.z = a
i.u = b
assert b.w.o.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: B = None
        self.u: C = None
        self.z: B = None
        self.txt = txt

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

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

m.o = b
a.q = i
a.z = i
a.u = b
b.w = m
l.o = b
i.q = a
i.z = a
i.u = b
assert b.w.o.w.o.txt == "b"