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

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

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

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

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

n.t = h
n.y = a
h.p = j
d.o = a
a.z = d
j.o = k
l.z = d
c.t = h
c.y = k
k.z = d
assert d.o.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.y: D = None
        self.txt = txt

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

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

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

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

n.t = h
n.y = a
h.p = j
d.o = a
a.z = d
j.o = k
l.z = d
c.t = h
c.y = k
k.z = d
assert d.o.z.o.txt == "a"