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

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

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.u: B = None
        self.t: A = None
        self.w: D = None
        self.v: A = None
        self.txt = txt

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

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

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

h.r = f
i.r = d
i.z = f
i.x = f
n.s = b
n.u = i
n.t = h
n.v = h
n.w = e
g.s = i
g.u = b
b.z = g
b.x = n
b.p = e
b.r = e
f.r = n
f.z = i
f.x = i
e.s = i
e.u = b
d.s = b
d.u = i
d.t = h
d.v = h
d.w = e
assert h.r.r.s.x.u.z.x.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.u: B = None
        self.t: A = None
        self.w: D = None
        self.v: A = None
        self.txt = txt

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

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

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

h.r = f
i.r = d
i.z = f
i.x = f
n.s = b
n.u = i
n.t = h
n.v = h
n.w = e
g.s = i
g.u = b
b.z = g
b.x = n
b.p = e
b.r = e
f.r = n
f.z = i
f.x = i
e.s = i
e.u = b
d.s = b
d.u = i
d.t = h
d.v = h
d.w = e
assert h.r.r.s.x.u.z.x.r.txt == "d"