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

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

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

class D:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: C = None
        self.p: A = None
        self.r: E = None
        self.txt = txt

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

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

l.u = g
j.u = c
j.w = h
e.o = h
e.p = c
e.r = f
d.x = f
d.q = e
d.p = h
d.r = c
c.q = j
g.q = j
n.x = d
n.q = e
n.p = h
n.r = c
h.u = c
f.x = d
f.q = e
f.p = h
f.r = c
b.o = l
b.p = c
b.r = f
assert d.x.x.x.r.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: C = None
        self.p: A = None
        self.r: E = None
        self.txt = txt

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

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

l.u = g
j.u = c
j.w = h
e.o = h
e.p = c
e.r = f
d.x = f
d.q = e
d.p = h
d.r = c
c.q = j
g.q = j
n.x = d
n.q = e
n.p = h
n.r = c
h.u = c
f.x = d
f.q = e
f.p = h
f.r = c
b.o = l
b.p = c
b.r = f
assert d.x.x.x.r.q.w.txt == "h"