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

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

a = A("a")
e = B("e")
b = A("b")
k = A("k")
h = A("h")
j = A("j")
c = B("c")
l = B("l")
n = B("n")

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

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

a = A("a")
e = B("e")
b = A("b")
k = A("k")
h = A("h")
j = A("j")
c = B("c")
l = B("l")
n = B("n")

a.u = k
e.s = l
b.u = a
k.u = a
h.u = j
j.u = b
c.s = l
l.s = e
n.s = l
assert c.s.s.s.s.s.s.txt == "e"