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

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

b = A("b")
h = B("h")
j = B("j")

b.x = j
h.v = j
j.v = h
assert h.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

b = A("b")
h = B("h")
j = B("j")

b.x = j
h.v = j
j.v = h
assert h.v.v.v.txt == "j"