class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.t: B = None
        self.w: D = None
        self.y: B = None
        self.txt = txt

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

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

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

h = A("h")
m = B("m")
k = C("k")
a = D("a")
g = B("g")
d = B("d")
e = C("e")

h.p = m
h.t = g
h.y = g
h.w = a
m.w = h
k.u = g
a.z = k
g.w = h
d.w = h
e.u = d
assert g.w.y.w.w.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.t: B = None
        self.w: D = None
        self.y: B = None
        self.txt = txt

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

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

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

h = A("h")
m = B("m")
k = C("k")
a = D("a")
g = B("g")
d = B("d")
e = C("e")

h.p = m
h.t = g
h.y = g
h.w = a
m.w = h
k.u = g
a.z = k
g.w = h
d.w = h
e.u = d
assert g.w.y.w.w.z.u.txt == "g"