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

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

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

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

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

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

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

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

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

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

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