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

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

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

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

n = A("n")
m = B("m")
i = C("i")
j = D("j")
a = D("a")
k = D("k")
h = C("h")

n.y = m
m.p = a
m.y = i
i.q = k
j.s = m
j.p = m
j.t = h
a.s = m
a.p = m
a.t = h
k.s = m
k.p = m
k.t = h
h.q = a
assert j.t.q.t.q.s.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

n = A("n")
m = B("m")
i = C("i")
j = D("j")
a = D("a")
k = D("k")
h = C("h")

n.y = m
m.p = a
m.y = i
i.q = k
j.s = m
j.p = m
j.t = h
a.s = m
a.p = m
a.t = h
k.s = m
k.p = m
k.t = h
h.q = a
assert j.t.q.t.q.s.y.q.txt == "k"