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

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

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

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

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

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

h.u = b
f.s = c
f.r = b
k.r = f
k.t = l
k.v = c
b.r = d
b.t = c
b.z = f
b.w = g
n.p = g
m.u = c
g.r = f
g.t = n
g.v = c
c.r = d
c.t = b
c.z = f
c.w = g
l.p = g
d.u = c
assert h.u.t.t.z.r.t.r.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

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

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

h.u = b
f.s = c
f.r = b
k.r = f
k.t = l
k.v = c
b.r = d
b.t = c
b.z = f
b.w = g
n.p = g
m.u = c
g.r = f
g.t = n
g.v = c
c.r = d
c.t = b
c.z = f
c.w = g
l.p = g
d.u = c
assert h.u.t.t.z.r.t.r.u.txt == "c"