class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

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

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

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

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

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

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

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

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

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

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