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

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

n = A("n")
h = B("h")
k = B("k")
b = B("b")
l = B("l")
i = B("i")
f = A("f")
d = A("d")
a = A("a")

n.u = k
h.z = n
k.z = f
b.z = a
l.z = f
i.z = f
f.u = i
d.u = k
a.u = b
assert d.u.z.u.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

n = A("n")
h = B("h")
k = B("k")
b = B("b")
l = B("l")
i = B("i")
f = A("f")
d = A("d")
a = A("a")

n.u = k
h.z = n
k.z = f
b.z = a
l.z = f
i.z = f
f.u = i
d.u = k
a.u = b
assert d.u.z.u.z.u.txt == "i"