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

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

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

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

m.v = f
m.o = n
f.o = m
f.q = m
n.w = f
assert f.o.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.o: C = None
        self.txt = txt

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

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

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

m.v = f
m.o = n
f.o = m
f.q = m
n.w = f
assert f.o.v.q.txt == "m"