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

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

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

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

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

j = A("j")
d = B("d")
n = C("n")
a = D("a")
k = E("k")

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

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

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

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

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

j = A("j")
d = B("d")
n = C("n")
a = D("a")
k = E("k")

j.z = n
d.u = n
d.w = a
d.z = k
n.r = j
a.y = j
k.o = j
k.s = d
assert a.y.z.r.z.r.txt == "j"