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

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

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.z: A = None
        self.txt = txt

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

k = A("k")
n = B("n")
j = C("j")
c = D("c")
i = E("i")
l = B("l")
f = B("f")
h = B("h")
b = A("b")
a = D("a")

k.p = l
k.u = c
k.s = i
k.r = i
n.r = j
n.w = c
j.o = c
j.w = c
j.t = l
c.y = j
c.z = k
i.x = a
l.r = j
l.w = c
f.r = j
f.w = a
h.r = j
h.w = a
b.p = l
b.u = a
b.s = i
b.r = i
a.y = j
a.z = k
assert h.r.t.w.z.u.y.w.y.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: D = None
        self.s: E = None
        self.r: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.z: A = None
        self.txt = txt

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

k = A("k")
n = B("n")
j = C("j")
c = D("c")
i = E("i")
l = B("l")
f = B("f")
h = B("h")
b = A("b")
a = D("a")

k.p = l
k.u = c
k.s = i
k.r = i
n.r = j
n.w = c
j.o = c
j.w = c
j.t = l
c.y = j
c.z = k
i.x = a
l.r = j
l.w = c
f.r = j
f.w = a
h.r = j
h.w = a
b.p = l
b.u = a
b.s = i
b.r = i
a.y = j
a.z = k
assert h.r.t.w.z.u.y.w.y.t.w.txt == "c"