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

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

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

n = A("n")
e = B("e")
g = C("g")
d = B("d")
k = A("k")
l = B("l")
a = C("a")

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

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

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

n = A("n")
e = B("e")
g = C("g")
d = B("d")
k = A("k")
l = B("l")
a = C("a")

n.o = d
n.u = l
e.o = a
e.u = a
e.q = n
g.q = l
g.y = k
d.o = a
d.u = g
d.q = n
k.o = l
k.u = l
l.o = g
l.u = a
l.q = k
a.q = e
a.y = n
assert d.u.q.u.q.q.o.u.txt == "g"