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

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

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

f = A("f")
m = B("m")
a = C("a")

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

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

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

f = A("f")
m = B("m")
a = C("a")

f.v = m
m.o = f
m.s = a
a.o = m
assert a.o.o.v.txt == "m"