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

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

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

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

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

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

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

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

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

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

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

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

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