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

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

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.r: E = None
        self.w: C = None
        self.txt = txt

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

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

k.w = m
e.w = n
h.z = m
h.t = e
h.r = k
m.t = n
m.r = n
m.w = h
n.s = e
n.r = h
g.z = m
g.t = e
g.r = k
assert e.w.s.w.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.r: E = None
        self.w: C = None
        self.txt = txt

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

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

k.w = m
e.w = n
h.z = m
h.t = e
h.r = k
m.t = n
m.r = n
m.w = h
n.s = e
n.r = h
g.z = m
g.t = e
g.r = k
assert e.w.s.w.r.z.txt == "m"