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

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

class C:
    def __init__(self, txt: str):
        self.u: B = None
        self.s: E = None
        self.txt = txt

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

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

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

k.w = d
k.q = h
c.v = g
c.y = g
c.z = d
h.u = c
h.s = g
d.s = k
d.w = g
d.v = c
g.w = h
g.v = d
g.q = c
assert h.s.w.s.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.q: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: B = None
        self.s: E = None
        self.txt = txt

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

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

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

k.w = d
k.q = h
c.v = g
c.y = g
c.z = d
h.u = c
h.s = g
d.s = k
d.w = g
d.v = c
g.w = h
g.v = d
g.q = c
assert h.s.w.s.v.w.txt == "g"