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

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

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

m = A("m")
c = B("c")
l = C("l")
e = A("e")
n = C("n")
f = C("f")
h = C("h")

m.o = e
m.q = e
m.r = c
c.t = m
c.q = h
l.z = m
e.o = m
e.q = m
e.r = c
n.z = m
f.z = m
h.z = m
assert c.q.z.r.q.z.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.q: A = None
        self.r: B = None
        self.txt = txt

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

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

m = A("m")
c = B("c")
l = C("l")
e = A("e")
n = C("n")
f = C("f")
h = C("h")

m.o = e
m.q = e
m.r = c
c.t = m
c.q = h
l.z = m
e.o = m
e.q = m
e.r = c
n.z = m
f.z = m
h.z = m
assert c.q.z.r.q.z.o.r.txt == "c"