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

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

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

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

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

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

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