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

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

m = A("m")
i = B("i")
n = A("n")
l = B("l")

m.o = n
i.t = l
i.p = n
n.o = m
l.t = i
l.p = n
assert n.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: B = None
        self.p: A = None
        self.txt = txt

m = A("m")
i = B("i")
n = A("n")
l = B("l")

m.o = n
i.t = l
i.p = n
n.o = m
l.t = i
l.p = n
assert n.o.o.o.o.txt == "n"