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

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

c = A("c")
g = B("g")
h = C("h")
m = D("m")
k = E("k")

c.w = g
g.y = m
g.w = k
h.s = g
h.q = g
h.v = g
h.p = c
h.z = c
m.y = h
m.z = h
m.v = g
k.r = g
assert h.q.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

c = A("c")
g = B("g")
h = C("h")
m = D("m")
k = E("k")

c.w = g
g.y = m
g.w = k
h.s = g
h.q = g
h.v = g
h.p = c
h.z = c
m.y = h
m.z = h
m.v = g
k.r = g
assert h.q.w.r.txt == "g"