class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.p: B = None
        self.u: C = None
        self.s: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: C = None
        self.x: C = None
        self.p: B = None
        self.w: B = None
        self.txt = txt

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

n = A("n")
k = B("k")
e = C("e")
d = D("d")
a = B("a")
i = C("i")
c = C("c")
h = D("h")

n.w = d
n.p = k
n.u = i
n.s = h
k.p = h
k.y = h
k.q = n
e.u = i
e.x = i
e.p = a
e.w = a
d.z = e
d.s = c
a.p = d
a.y = h
a.q = n
i.u = e
i.x = e
i.p = k
i.w = a
c.u = e
c.x = i
c.p = a
c.w = a
h.z = e
h.s = c
assert k.q.u.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.p: B = None
        self.u: C = None
        self.s: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: C = None
        self.x: C = None
        self.p: B = None
        self.w: B = None
        self.txt = txt

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

n = A("n")
k = B("k")
e = C("e")
d = D("d")
a = B("a")
i = C("i")
c = C("c")
h = D("h")

n.w = d
n.p = k
n.u = i
n.s = h
k.p = h
k.y = h
k.q = n
e.u = i
e.x = i
e.p = a
e.w = a
d.z = e
d.s = c
a.p = d
a.y = h
a.q = n
i.u = e
i.x = e
i.p = k
i.w = a
c.u = e
c.x = i
c.p = a
c.w = a
h.z = e
h.s = c
assert k.q.u.w.q.txt == "n"