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

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

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.y: A = 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.p: C = None
        self.txt = txt

g = A("g")
l = B("l")
i = C("i")
k = D("k")
e = E("e")
a = B("a")
c = C("c")

g.o = k
l.z = g
l.y = g
l.r = a
l.t = a
l.q = k
i.q = a
i.y = g
k.q = e
e.p = c
a.z = g
a.y = g
a.r = l
a.t = l
a.q = k
c.q = l
c.y = g
assert g.o.q.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: B = None
        self.y: A = 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.p: C = None
        self.txt = txt

g = A("g")
l = B("l")
i = C("i")
k = D("k")
e = E("e")
a = B("a")
c = C("c")

g.o = k
l.z = g
l.y = g
l.r = a
l.t = a
l.q = k
i.q = a
i.y = g
k.q = e
e.p = c
a.z = g
a.y = g
a.r = l
a.t = l
a.q = k
c.q = l
c.y = g
assert g.o.q.p.q.txt == "l"