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

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

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

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

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

e.r = n
e.u = n
e.x = h
h.x = j
h.p = j
h.z = i
h.r = a
j.t = h
j.x = c
n.r = a
a.r = n
i.r = d
i.u = d
i.x = h
d.r = n
c.x = j
c.p = j
c.z = e
c.r = n
assert c.z.x.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.u: D = None
        self.x: B = None
        self.txt = txt

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

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

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

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

e.r = n
e.u = n
e.x = h
h.x = j
h.p = j
h.z = i
h.r = a
j.t = h
j.x = c
n.r = a
a.r = n
i.r = d
i.u = d
i.x = h
d.r = n
c.x = j
c.p = j
c.z = e
c.r = n
assert c.z.x.p.t.txt == "h"