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

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

a = A("a")
l = B("l")
h = A("h")
c = B("c")

a.t = c
l.x = a
l.v = h
h.t = l
c.x = h
c.v = a
assert h.t.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

a = A("a")
l = B("l")
h = A("h")
c = B("c")

a.t = c
l.x = a
l.v = h
h.t = l
c.x = h
c.v = a
assert h.t.v.t.txt == "l"