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

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

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

n = A("n")
l = B("l")
h = C("h")
e = A("e")
f = A("f")
g = C("g")
d = B("d")
b = C("b")
k = A("k")

n.z = k
l.o = b
l.x = b
l.t = d
h.u = f
e.z = n
f.z = n
g.u = n
d.o = g
d.t = l
d.x = b
b.u = e
k.z = f
assert b.u.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

n = A("n")
l = B("l")
h = C("h")
e = A("e")
f = A("f")
g = C("g")
d = B("d")
b = C("b")
k = A("k")

n.z = k
l.o = b
l.x = b
l.t = d
h.u = f
e.z = n
f.z = n
g.u = n
d.o = g
d.t = l
d.x = b
b.u = e
k.z = f
assert b.u.z.z.z.z.txt == "n"