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

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

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

m = A("m")
b = B("b")
a = C("a")
e = B("e")

m.z = a
m.v = e
b.w = m
b.r = a
a.y = b
e.w = m
e.r = a
assert m.z.y.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.v: B = None
        self.txt = txt

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

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

m = A("m")
b = B("b")
a = C("a")
e = B("e")

m.z = a
m.v = e
b.w = m
b.r = a
a.y = b
e.w = m
e.r = a
assert m.z.y.w.z.txt == "a"