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

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

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

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

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

i.u = j
i.w = e
a.z = e
a.t = e
a.x = e
a.r = j
e.x = a
h.x = n
h.w = a
h.z = e
j.u = i
j.w = e
n.z = e
n.t = e
n.x = e
n.r = i
assert i.w.x.r.w.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.w: C = None
        self.txt = txt

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

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

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

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

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