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

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

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

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

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

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

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

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

e.o = f
e.u = d
a.x = n
g.q = j
l.q = c
c.x = g
n.q = c
f.x = n
d.o = j
d.u = e
k.q = c
j.x = k
assert e.o.x.q.x.q.x.q.x.txt == "g"