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

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

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

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

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

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

b.u = f
b.p = d
e.y = l
e.x = d
e.o = n
l.p = m
l.z = d
l.x = e
c.q = n
c.y = e
f.p = e
g.p = m
g.z = d
g.x = d
n.q = c
n.y = e
m.p = l
m.z = e
m.x = d
a.u = f
a.p = e
d.y = g
d.x = e
d.o = c
assert m.p.z.y.p.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: E = None
        self.p: B = None
        self.txt = txt

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

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

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

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

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

b.u = f
b.p = d
e.y = l
e.x = d
e.o = n
l.p = m
l.z = d
l.x = e
c.q = n
c.y = e
f.p = e
g.p = m
g.z = d
g.x = d
n.q = c
n.y = e
m.p = l
m.z = e
m.x = d
a.u = f
a.p = e
d.y = g
d.x = e
d.o = c
assert m.p.z.y.p.z.o.txt == "n"