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

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

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

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

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

n = A("n")
a = B("a")
d = C("d")
h = D("h")
c = E("c")
m = E("m")
i = A("i")
g = A("g")

n.w = g
n.z = m
n.q = c
a.p = h
a.y = n
d.o = g
d.z = a
h.o = a
c.y = a
c.t = h
m.y = a
m.t = h
i.w = n
i.z = m
i.q = c
g.w = n
g.z = c
g.q = c
assert i.z.t.o.p.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.z: E = None
        self.q: E = None
        self.txt = txt

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

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

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

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

n = A("n")
a = B("a")
d = C("d")
h = D("h")
c = E("c")
m = E("m")
i = A("i")
g = A("g")

n.w = g
n.z = m
n.q = c
a.p = h
a.y = n
d.o = g
d.z = a
h.o = a
c.y = a
c.t = h
m.y = a
m.t = h
i.w = n
i.z = m
i.q = c
g.w = n
g.z = c
g.q = c
assert i.z.t.o.p.o.p.txt == "h"