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

f = A("f")
c = B("c")
k = B("k")

f.y = k
c.o = f
k.o = f
assert c.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

f = A("f")
c = B("c")
k = B("k")

f.y = k
c.o = f
k.o = f
assert c.o.y.o.txt == "f"