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

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

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

g = A("g")
h = B("h")
c = C("c")
i = C("i")
f = A("f")
m = B("m")
n = C("n")

g.q = m
g.u = m
h.w = m
h.u = i
c.p = i
c.z = h
i.p = n
i.z = h
f.q = m
f.u = h
m.w = h
m.u = c
n.p = c
n.z = h
assert h.u.p.p.p.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.u: B = None
        self.txt = txt

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

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

g = A("g")
h = B("h")
c = C("c")
i = C("i")
f = A("f")
m = B("m")
n = C("n")

g.q = m
g.u = m
h.w = m
h.u = i
c.p = i
c.z = h
i.p = n
i.z = h
f.q = m
f.u = h
m.w = h
m.u = c
n.p = c
n.z = h
assert h.u.p.p.p.z.w.txt == "m"