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

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

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

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

e.z = m
e.w = b
m.s = b
m.w = b
m.v = b
b.s = m
b.p = m
assert e.w.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.w: C = None
        self.txt = txt

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

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

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

e.z = m
e.w = b
m.s = b
m.w = b
m.v = b
b.s = m
b.p = m
assert e.w.p.s.txt == "b"