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

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

n = A("n")
d = B("d")
b = B("b")
i = B("i")
k = B("k")

n.p = d
d.p = b
b.p = i
i.p = k
k.p = d
assert b.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

n = A("n")
d = B("d")
b = B("b")
i = B("i")
k = B("k")

n.p = d
d.p = b
b.p = i
i.p = k
k.p = d
assert b.p.p.p.p.p.txt == "i"