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

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

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

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

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

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

h.t = b
e.v = a
a.v = e
b.t = h
i.t = b
assert h.t.t.t.t.t.txt == "b"