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

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

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

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

g = A("g")
c = B("c")
i = C("i")
n = D("n")
a = C("a")
j = D("j")
h = B("h")
f = C("f")

g.z = h
c.z = h
i.y = h
i.r = h
i.u = c
i.s = a
n.r = c
n.v = j
a.y = c
a.u = c
a.s = f
a.r = h
j.r = c
j.v = n
h.z = c
f.y = c
f.u = h
f.r = h
f.s = i
assert n.v.v.r.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

g = A("g")
c = B("c")
i = C("i")
n = D("n")
a = C("a")
j = D("j")
h = B("h")
f = C("f")

g.z = h
c.z = h
i.y = h
i.r = h
i.u = c
i.s = a
n.r = c
n.v = j
a.y = c
a.u = c
a.s = f
a.r = h
j.r = c
j.v = n
h.z = c
f.y = c
f.u = h
f.r = h
f.s = i
assert n.v.v.r.z.z.z.z.z.txt == "h"