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

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

a = A("a")
m = B("m")
l = B("l")

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

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

a = A("a")
m = B("m")
l = B("l")

a.t = l
a.o = l
m.q = a
l.q = a
assert a.o.q.o.txt == "l"