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

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

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

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

b.v = a
b.w = a
b.x = f
f.x = b
f.o = b
a.p = f
c.v = a
c.w = a
c.x = f
assert f.x.x.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.x: B = None
        self.w: C = None
        self.txt = txt

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

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

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

b.v = a
b.w = a
b.x = f
f.x = b
f.o = b
a.p = f
c.v = a
c.w = a
c.x = f
assert f.x.x.x.w.txt == "a"