class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.s: D = None
        self.y: C = None
        self.u: C = None
        self.txt = txt

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

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

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

a = A("a")
m = B("m")
e = C("e")
c = D("c")
i = B("i")
l = C("l")

a.r = m
a.s = c
a.y = l
a.u = l
m.s = a
e.r = c
e.w = c
e.z = l
c.o = a
c.w = a
c.t = i
i.s = a
l.r = c
l.w = c
l.z = e
assert l.z.w.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.s: D = None
        self.y: C = None
        self.u: C = None
        self.txt = txt

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

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

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

a = A("a")
m = B("m")
e = C("e")
c = D("c")
i = B("i")
l = C("l")

a.r = m
a.s = c
a.y = l
a.u = l
m.s = a
e.r = c
e.w = c
e.z = l
c.o = a
c.w = a
c.t = i
i.s = a
l.r = c
l.w = c
l.z = e
assert l.z.w.w.r.txt == "m"