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

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

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

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

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

g = A("g")
j = B("j")
n = C("n")
d = D("d")
c = E("c")
e = A("e")
a = C("a")
l = E("l")

g.q = e
j.x = n
j.u = c
j.p = g
j.s = l
n.r = j
n.t = d
n.x = g
d.u = g
d.s = g
d.y = n
d.r = a
c.t = l
c.y = e
c.z = d
e.q = g
a.r = j
a.t = d
a.x = g
l.t = c
l.y = g
l.z = d
assert g.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

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

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

g = A("g")
j = B("j")
n = C("n")
d = D("d")
c = E("c")
e = A("e")
a = C("a")
l = E("l")

g.q = e
j.x = n
j.u = c
j.p = g
j.s = l
n.r = j
n.t = d
n.x = g
d.u = g
d.s = g
d.y = n
d.r = a
c.t = l
c.y = e
c.z = d
e.q = g
a.r = j
a.t = d
a.x = g
l.t = c
l.y = g
l.z = d
assert g.q.q.q.q.q.txt == "e"