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

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

l = A("l")
j = B("j")
f = A("f")
i = A("i")
m = A("m")
h = B("h")
e = A("e")
c = A("c")
g = A("g")
b = B("b")

l.u = e
l.s = h
j.z = h
f.u = l
f.s = j
i.u = c
i.s = h
m.u = i
m.s = h
h.z = b
e.u = f
e.s = h
c.u = f
c.s = b
g.u = i
g.s = h
b.z = j
assert j.z.z.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.s: B = None
        self.txt = txt

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

l = A("l")
j = B("j")
f = A("f")
i = A("i")
m = A("m")
h = B("h")
e = A("e")
c = A("c")
g = A("g")
b = B("b")

l.u = e
l.s = h
j.z = h
f.u = l
f.s = j
i.u = c
i.s = h
m.u = i
m.s = h
h.z = b
e.u = f
e.s = h
c.u = f
c.s = b
g.u = i
g.s = h
b.z = j
assert j.z.z.z.z.z.z.txt == "j"