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

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

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

l = A("l")
i = B("i")
a = C("a")
b = C("b")
c = A("c")
m = B("m")
n = A("n")

l.r = m
i.s = a
i.z = b
i.x = l
a.w = i
b.w = m
c.r = m
m.s = a
m.z = a
m.x = n
n.r = i
assert c.r.s.w.s.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

l = A("l")
i = B("i")
a = C("a")
b = C("b")
c = A("c")
m = B("m")
n = A("n")

l.r = m
i.s = a
i.z = b
i.x = l
a.w = i
b.w = m
c.r = m
m.s = a
m.z = a
m.x = n
n.r = i
assert c.r.s.w.s.w.z.txt == "b"