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

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.v: B = None
        self.txt = txt

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

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

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

class B:
    def __init__(self, txt: str):
        self.z: B = None
        self.v: B = None
        self.txt = txt

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

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

e.q = a
n.z = k
n.v = k
a.u = d
d.q = a
k.z = n
k.v = g
g.z = k
g.v = n
j.u = e
assert n.z.z.v.z.v.z.txt == "n"