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

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

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

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

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

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

n.z = i
n.r = l
g.t = i
g.v = i
g.r = n
g.u = l
g.q = l
l.r = e
l.x = a
i.q = h
a.r = e
a.q = i
h.r = e
h.q = i
e.t = i
e.v = i
e.r = n
e.u = l
e.q = l
assert l.r.q.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.r: C = None
        self.txt = txt

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

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

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

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

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

n.z = i
n.r = l
g.t = i
g.v = i
g.r = n
g.u = l
g.q = l
l.r = e
l.x = a
i.q = h
a.r = e
a.q = i
h.r = e
h.q = i
e.t = i
e.v = i
e.r = n
e.u = l
e.q = l
assert l.r.q.r.r.r.txt == "l"