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

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

f = A("f")
g = B("g")
a = B("a")
k = B("k")
i = A("i")
h = A("h")
l = A("l")
n = A("n")
m = B("m")

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

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

f = A("f")
g = B("g")
a = B("a")
k = B("k")
i = A("i")
h = A("h")
l = A("l")
n = A("n")
m = B("m")

f.y = g
g.z = m
g.u = k
a.z = k
a.u = g
k.z = g
k.u = m
i.y = a
h.y = m
l.y = m
n.y = g
m.z = k
m.u = g
assert h.y.z.z.z.u.z.z.u.z.txt == "k"