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

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

l = A("l")
j = B("j")
e = B("e")
d = B("d")
i = A("i")
h = A("h")
f = A("f")
n = B("n")
m = B("m")
a = A("a")

l.y = m
l.u = a
j.s = m
e.s = j
d.s = j
i.y = e
i.u = f
h.y = e
h.u = i
f.y = n
f.u = a
n.s = j
m.s = j
a.y = d
a.u = f
assert l.u.u.y.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.u: A = None
        self.txt = txt

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

l = A("l")
j = B("j")
e = B("e")
d = B("d")
i = A("i")
h = A("h")
f = A("f")
n = B("n")
m = B("m")
a = A("a")

l.y = m
l.u = a
j.s = m
e.s = j
d.s = j
i.y = e
i.u = f
h.y = e
h.u = i
f.y = n
f.u = a
n.s = j
m.s = j
a.y = d
a.u = f
assert l.u.u.y.s.s.s.txt == "j"