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

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

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

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

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

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

f.o = m
m.o = i
c.o = i
i.o = c
assert c.o.o.o.txt == "i"