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

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

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

a.y = c
a.s = c
c.o = a
f.o = a
assert a.y.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.s: B = None
        self.txt = txt

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

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

a.y = c
a.s = c
c.o = a
f.o = a
assert a.y.o.y.txt == "c"