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

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

m = A("m")
n = B("n")
c = A("c")

m.o = c
n.u = c
c.o = m
assert c.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.u: A = None
        self.txt = txt

m = A("m")
n = B("n")
c = A("c")

m.o = c
n.u = c
c.o = m
assert c.o.o.o.txt == "m"