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

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

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

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

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

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

e.s = a
b.p = k
i.p = a
c.p = i
k.p = i
l.s = a
a.p = b
g.s = k
j.s = a
h.s = i
assert e.s.p.p.p.txt == "i"