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

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

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

k = A("k")
h = B("h")
g = C("g")
c = C("c")
e = B("e")
d = B("d")

k.s = d
k.w = d
k.u = c
h.q = c
h.r = c
h.z = e
g.p = e
c.p = h
e.q = g
e.r = c
e.z = d
d.q = c
d.r = g
d.z = e
assert e.r.p.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.u: C = None
        self.w: B = None
        self.txt = txt

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

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

k = A("k")
h = B("h")
g = C("g")
c = C("c")
e = B("e")
d = B("d")

k.s = d
k.w = d
k.u = c
h.q = c
h.r = c
h.z = e
g.p = e
c.p = h
e.q = g
e.r = c
e.z = d
d.q = c
d.r = g
d.z = e
assert e.r.p.z.z.txt == "d"