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

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

k = A("k")
b = B("b")
e = A("e")
f = B("f")
l = A("l")

k.s = e
b.p = f
b.s = f
e.s = k
f.p = b
f.s = b
l.s = e
assert b.p.s.p.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

k = A("k")
b = B("b")
e = A("e")
f = B("f")
l = A("l")

k.s = e
b.p = f
b.s = f
e.s = k
f.p = b
f.s = b
l.s = e
assert b.p.s.p.p.s.txt == "f"