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

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

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

l = A("l")
e = B("e")
m = C("m")

l.s = e
e.w = l
e.q = l
e.p = m
m.p = e
m.r = e
m.x = e
assert l.s.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

l = A("l")
e = B("e")
m = C("m")

l.s = e
e.w = l
e.q = l
e.p = m
m.p = e
m.r = e
m.x = e
assert l.s.p.p.txt == "e"