class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: E = None
        self.v: E = None
        self.z: D = None
        self.p: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.x: E = None
        self.w: A = None
        self.z: C = None
        self.s: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

c = A("c")
d = B("d")
h = C("h")
f = D("f")
m = E("m")

c.y = f
d.y = m
d.v = m
d.z = f
d.p = f
h.z = d
f.x = m
f.w = c
f.z = h
f.s = h
m.z = h
assert c.y.w.y.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: E = None
        self.v: E = None
        self.z: D = None
        self.p: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.x: E = None
        self.w: A = None
        self.z: C = None
        self.s: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

c = A("c")
d = B("d")
h = C("h")
f = D("f")
m = E("m")

c.y = f
d.y = m
d.v = m
d.z = f
d.p = f
h.z = d
f.x = m
f.w = c
f.z = h
f.s = h
m.z = h
assert c.y.w.y.s.z.txt == "d"