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

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

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

m = A("m")
e = B("e")
f = C("f")
j = B("j")
c = C("c")

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

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

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

m = A("m")
e = B("e")
f = C("f")
j = B("j")
c = C("c")

m.x = c
m.z = j
e.w = f
e.v = j
f.w = j
j.w = f
j.v = e
c.w = e
assert m.x.w.w.txt == "f"