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

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

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

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

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

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

f.v = k
k.s = h
h.s = k
assert h.s.s.s.txt == "k"