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

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

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

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

h = A("h")
k = B("k")
e = C("e")
n = D("n")
i = C("i")
j = C("j")
l = B("l")
g = A("g")
d = C("d")

h.z = j
h.p = n
h.r = k
h.t = e
k.w = l
e.s = h
n.o = l
i.s = g
j.s = g
l.w = k
g.z = e
g.p = n
g.r = k
g.t = i
d.s = g
assert h.r.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.p: D = None
        self.r: B = None
        self.t: C = None
        self.txt = txt

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

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

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

h = A("h")
k = B("k")
e = C("e")
n = D("n")
i = C("i")
j = C("j")
l = B("l")
g = A("g")
d = C("d")

h.z = j
h.p = n
h.r = k
h.t = e
k.w = l
e.s = h
n.o = l
i.s = g
j.s = g
l.w = k
g.z = e
g.p = n
g.r = k
g.t = i
d.s = g
assert h.r.w.w.w.w.w.txt == "l"