class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.o: C = None
        self.p: E = None
        self.z: D = None
        self.q: C = None
        self.txt = txt

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

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

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

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

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

a.s = d
a.z = d
a.o = n
a.q = n
a.p = h
e.s = c
e.y = f
n.p = h
n.o = e
n.s = e
d.q = e
m.x = h
k.x = m
g.s = f
g.o = n
g.q = n
g.p = m
g.z = d
h.x = m
c.s = e
c.y = d
f.q = e
assert n.p.x.x.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.o: C = None
        self.p: E = None
        self.z: D = None
        self.q: C = None
        self.txt = txt

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

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

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

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

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

a.s = d
a.z = d
a.o = n
a.q = n
a.p = h
e.s = c
e.y = f
n.p = h
n.o = e
n.s = e
d.q = e
m.x = h
k.x = m
g.s = f
g.o = n
g.q = n
g.p = m
g.z = d
h.x = m
c.s = e
c.y = d
f.q = e
assert n.p.x.x.x.x.x.x.x.x.txt == "h"