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

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

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

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

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

b = A("b")
m = B("m")
n = C("n")
i = D("i")
a = E("a")
h = A("h")
d = D("d")
l = C("l")
e = B("e")
k = A("k")

b.x = m
b.r = i
m.w = b
m.o = a
m.u = a
n.o = m
i.y = d
i.x = a
i.q = n
a.u = k
h.x = m
h.r = d
d.y = i
d.x = a
d.q = n
l.o = m
e.w = h
e.o = a
e.u = a
k.x = m
k.r = d
assert i.y.x.u.x.w.x.w.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.r: D = None
        self.txt = txt

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

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

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

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

b = A("b")
m = B("m")
n = C("n")
i = D("i")
a = E("a")
h = A("h")
d = D("d")
l = C("l")
e = B("e")
k = A("k")

b.x = m
b.r = i
m.w = b
m.o = a
m.u = a
n.o = m
i.y = d
i.x = a
i.q = n
a.u = k
h.x = m
h.r = d
d.y = i
d.x = a
d.q = n
l.o = m
e.w = h
e.o = a
e.u = a
k.x = m
k.r = d
assert i.y.x.u.x.w.x.w.r.y.txt == "d"