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

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

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

e = A("e")
h = B("h")
f = C("f")
m = B("m")

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

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

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

e = A("e")
h = B("h")
f = C("f")
m = B("m")

e.v = h
e.q = f
e.z = f
h.x = e
h.y = e
h.w = e
f.w = e
f.o = e
m.x = e
m.y = e
m.w = e
assert f.w.z.w.q.txt == "f"