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

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

l = A("l")
c = B("c")
e = A("e")
i = B("i")
k = A("k")
h = B("h")
m = B("m")
f = A("f")
d = A("d")
n = B("n")

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

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

l = A("l")
c = B("c")
e = A("e")
i = B("i")
k = A("k")
h = B("h")
m = B("m")
f = A("f")
d = A("d")
n = B("n")

l.s = c
l.p = e
c.u = d
e.s = n
e.p = l
i.u = e
k.s = h
k.p = d
h.u = e
m.u = k
f.s = i
f.p = k
d.s = m
d.p = e
n.u = f
assert h.u.s.u.s.u.txt == "e"