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

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

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

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

m = A("m")
h = B("h")
g = C("g")
a = D("a")
c = C("c")
k = B("k")
d = A("d")
l = D("l")

m.z = a
h.u = k
h.s = m
h.r = c
g.z = l
g.w = c
g.r = h
a.w = l
c.z = l
c.w = g
c.r = h
k.u = h
k.s = d
k.r = g
d.z = l
l.w = a
assert l.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

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

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

m = A("m")
h = B("h")
g = C("g")
a = D("a")
c = C("c")
k = B("k")
d = A("d")
l = D("l")

m.z = a
h.u = k
h.s = m
h.r = c
g.z = l
g.w = c
g.r = h
a.w = l
c.z = l
c.w = g
c.r = h
k.u = h
k.s = d
k.r = g
d.z = l
l.w = a
assert l.w.w.w.w.txt == "l"