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

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

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

g = A("g")
a = B("a")
i = C("i")
l = C("l")
e = C("e")
j = A("j")
n = B("n")

g.q = n
a.o = n
a.y = e
i.q = e
i.z = j
l.q = e
l.z = j
e.q = l
e.z = g
j.q = n
n.o = a
n.y = e
assert g.q.y.q.q.z.q.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

g = A("g")
a = B("a")
i = C("i")
l = C("l")
e = C("e")
j = A("j")
n = B("n")

g.q = n
a.o = n
a.y = e
i.q = e
i.z = j
l.q = e
l.z = j
e.q = l
e.z = g
j.q = n
n.o = a
n.y = e
assert g.q.y.q.q.z.q.y.txt == "e"