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

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

i = A("i")
e = B("e")
b = A("b")

i.o = b
i.y = b
e.o = i
e.s = i
b.o = i
b.y = i
assert i.y.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.y: A = None
        self.txt = txt

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

i = A("i")
e = B("e")
b = A("b")

i.o = b
i.y = b
e.o = i
e.s = i
b.o = i
b.y = i
assert i.y.o.y.txt == "b"