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

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

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

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

k = A("k")
m = B("m")
c = C("c")
n = D("n")
a = B("a")
e = C("e")

k.u = n
m.w = c
m.z = a
c.z = e
c.w = k
n.y = m
a.w = c
a.z = m
e.z = c
e.w = k
assert c.w.u.y.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

k = A("k")
m = B("m")
c = C("c")
n = D("n")
a = B("a")
e = C("e")

k.u = n
m.w = c
m.z = a
c.z = e
c.w = k
n.y = m
a.w = c
a.z = m
e.z = c
e.w = k
assert c.w.u.y.w.txt == "c"