class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

d = A("d")
j = B("j")
k = C("k")
n = D("n")
h = A("h")
i = D("i")
e = A("e")

d.u = k
j.s = d
j.p = k
k.p = n
n.x = i
n.u = i
n.z = j
n.r = k
h.u = k
i.x = n
i.u = n
i.z = j
i.r = k
e.u = k
assert i.u.z.p.p.x.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

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

d = A("d")
j = B("j")
k = C("k")
n = D("n")
h = A("h")
i = D("i")
e = A("e")

d.u = k
j.s = d
j.p = k
k.p = n
n.x = i
n.u = i
n.z = j
n.r = k
h.u = k
i.x = n
i.u = n
i.z = j
i.r = k
e.u = k
assert i.u.z.p.p.x.r.p.txt == "n"