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

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

j = A("j")
l = B("l")
b = A("b")
m = B("m")
c = B("c")
k = A("k")
d = B("d")
f = A("f")
g = A("g")
i = A("i")

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

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

j = A("j")
l = B("l")
b = A("b")
m = B("m")
c = B("c")
k = A("k")
d = B("d")
f = A("f")
g = A("g")
i = A("i")

j.s = d
l.u = c
b.s = l
m.u = c
c.u = l
k.s = m
d.u = l
f.s = m
g.s = d
i.s = d
assert b.s.u.u.txt == "l"