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

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

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

l.t = e
j.p = a
j.s = m
m.p = j
m.s = j
a.p = j
a.s = j
f.t = e
e.t = f
i.p = a
i.s = a
assert j.p.s.s.s.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

l.t = e
j.p = a
j.s = m
m.p = j
m.s = j
a.p = j
a.s = j
f.t = e
e.t = f
i.p = a
i.s = a
assert j.p.s.s.s.p.p.txt == "j"