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.y: A = None
        self.txt = txt

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

b = A("b")
h = B("h")
c = C("c")

b.s = h
h.p = c
h.y = b
c.p = b
assert b.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.p: C = None
        self.y: A = None
        self.txt = txt

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

b = A("b")
h = B("h")
c = C("c")

b.s = h
h.p = c
h.y = b
c.p = b
assert b.s.p.p.txt == "b"