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

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

h = A("h")
b = B("b")
n = A("n")
c = A("c")
a = B("a")
i = B("i")
k = B("k")

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

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

h = A("h")
b = B("b")
n = A("n")
c = A("c")
a = B("a")
i = B("i")
k = B("k")

h.p = a
h.s = b
b.p = i
n.p = b
n.s = k
c.p = i
c.s = a
a.p = i
i.p = k
k.p = i
assert i.p.p.p.p.p.p.txt == "i"