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

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

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

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

g = A("g")
i = B("i")
c = C("c")
a = D("a")
l = A("l")
k = B("k")
n = D("n")
h = A("h")

g.z = a
i.s = k
i.v = a
c.w = n
c.u = i
a.t = l
l.z = a
k.s = i
k.v = n
n.t = l
h.z = a
assert n.t.z.t.z.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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

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

g = A("g")
i = B("i")
c = C("c")
a = D("a")
l = A("l")
k = B("k")
n = D("n")
h = A("h")

g.z = a
i.s = k
i.v = a
c.w = n
c.u = i
a.t = l
l.z = a
k.s = i
k.v = n
n.t = l
h.z = a
assert n.t.z.t.z.t.z.txt == "a"