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

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

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

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

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

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

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

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

a.y = d
a.u = n
n.q = a
n.z = j
g.y = a
k.y = a
l.y = d
l.u = n
d.y = a
j.y = a
assert g.y.u.q.u.z.txt == "j"