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

b = A("b")
f = B("f")
c = B("c")
m = A("m")

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

b = A("b")
f = B("f")
c = B("c")
m = A("m")

b.y = f
f.o = b
c.o = m
m.y = c
assert m.y.o.y.txt == "c"