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

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

f = A("f")
h = B("h")
c = B("c")

f.s = c
h.s = c
c.s = h
assert c.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

f = A("f")
h = B("h")
c = B("c")

f.s = c
h.s = c
c.s = h
assert c.s.s.s.txt == "h"