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

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

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

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

l.p = m
l.z = d
d.u = m
d.w = m
d.y = l
m.w = d
m.z = d
m.o = d
assert l.z.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.z: B = None
        self.txt = txt

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

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

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

l.p = m
l.z = d
d.u = m
d.w = m
d.y = l
m.w = d
m.z = d
m.o = d
assert l.z.y.p.txt == "m"