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

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

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

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

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

k.z = a
l.r = g
l.z = h
l.y = k
g.q = n
g.w = n
g.s = a
a.z = g
a.o = g
a.r = g
h.z = j
j.z = g
j.o = g
j.r = g
n.z = g
n.o = g
n.r = g
assert k.z.z.q.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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

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

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

k.z = a
l.r = g
l.z = h
l.y = k
g.q = n
g.w = n
g.s = a
a.z = g
a.o = g
a.r = g
h.z = j
j.z = g
j.o = g
j.r = g
n.z = g
n.o = g
n.r = g
assert k.z.z.q.r.s.txt == "a"