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

c = A("c")
k = B("k")
d = B("d")
n = A("n")
j = A("j")
e = A("e")
l = B("l")
i = A("i")

c.s = i
k.p = l
d.p = l
n.s = i
j.s = i
e.s = j
l.p = k
i.s = j
assert d.p.p.p.p.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

c = A("c")
k = B("k")
d = B("d")
n = A("n")
j = A("j")
e = A("e")
l = B("l")
i = A("i")

c.s = i
k.p = l
d.p = l
n.s = i
j.s = i
e.s = j
l.p = k
i.s = j
assert d.p.p.p.p.p.p.p.p.txt == "k"