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

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

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

b = A("b")
k = B("k")
i = C("i")
m = C("m")
c = B("c")
l = A("l")

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

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

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

b = A("b")
k = B("k")
i = C("i")
m = C("m")
c = B("c")
l = A("l")

b.w = k
b.o = k
k.z = c
i.q = c
m.q = k
c.z = k
l.w = c
l.o = c
assert m.q.z.z.z.z.z.txt == "c"