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

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

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

a = A("a")
h = B("h")
e = C("e")

a.s = h
h.p = e
h.w = a
e.y = h
e.v = a
assert h.w.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

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

a = A("a")
h = B("h")
e = C("e")

a.s = h
h.p = e
h.w = a
e.y = h
e.v = a
assert h.w.s.p.txt == "e"