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

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

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

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

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

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

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

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

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

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

n.z = i
n.u = a
n.r = a
e.o = a
i.x = j
j.y = i
j.z = i
j.w = n
a.z = i
a.u = n
a.r = n
assert j.w.u.z.txt == "i"