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

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

i = A("i")
a = B("a")
b = B("b")
l = A("l")

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

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

i = A("i")
a = B("a")
b = B("b")
l = A("l")

i.t = b
a.q = b
a.v = i
b.q = a
b.v = i
l.t = b
assert l.t.v.t.q.txt == "a"