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

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

j = A("j")
d = B("d")
e = A("e")
a = A("a")
k = B("k")
n = A("n")
i = A("i")
l = A("l")

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

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

j = A("j")
d = B("d")
e = A("e")
a = A("a")
k = B("k")
n = A("n")
i = A("i")
l = A("l")

j.u = e
d.s = e
e.u = a
a.u = n
k.s = a
n.u = l
i.u = j
l.u = i
assert i.u.u.u.u.u.txt == "l"