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

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

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

j = A("j")
c = B("c")
m = C("m")
i = B("i")
l = A("l")

j.w = m
j.q = c
c.x = i
m.z = l
m.s = i
i.x = c
l.w = m
l.q = c
assert m.s.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.q: B = None
        self.txt = txt

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

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

j = A("j")
c = B("c")
m = C("m")
i = B("i")
l = A("l")

j.w = m
j.q = c
c.x = i
m.z = l
m.s = i
i.x = c
l.w = m
l.q = c
assert m.s.x.x.txt == "i"