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

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

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

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

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

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

i.y = k
k.o = i
e.y = k
assert k.o.y.o.txt == "i"