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.txt = txt

b = A("b")
l = B("l")
f = A("f")
h = A("h")
n = B("n")
k = B("k")

b.s = h
l.p = k
f.s = b
h.s = f
n.p = k
k.p = l
assert k.p.p.p.p.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.txt = txt

b = A("b")
l = B("l")
f = A("f")
h = A("h")
n = B("n")
k = B("k")

b.s = h
l.p = k
f.s = b
h.s = f
n.p = k
k.p = l
assert k.p.p.p.p.txt == "k"