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

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

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

m.y = l
i.x = l
i.o = l
l.y = m
assert i.o.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

m.y = l
i.x = l
i.o = l
l.y = m
assert i.o.y.y.txt == "l"