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

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

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

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

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

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

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