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

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

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

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

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

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

b.s = e
e.v = b
e.s = b
h.v = b
h.s = b
a.v = b
a.s = b
assert a.v.s.v.txt == "b"