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

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

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

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

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

h = A("h")
g = B("g")
n = C("n")
k = D("k")
l = E("l")
e = D("e")

h.r = e
h.y = l
g.p = n
n.s = h
n.x = l
n.t = g
n.w = g
n.p = e
k.r = h
k.v = h
k.u = h
l.r = e
e.r = h
e.v = h
e.u = h
assert n.x.r.r.r.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.y: E = None
        self.txt = txt

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

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

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

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

h = A("h")
g = B("g")
n = C("n")
k = D("k")
l = E("l")
e = D("e")

h.r = e
h.y = l
g.p = n
n.s = h
n.x = l
n.t = g
n.w = g
n.p = e
k.r = h
k.v = h
k.u = h
l.r = e
e.r = h
e.v = h
e.u = h
assert n.x.r.r.r.r.y.txt == "l"