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")
e = B("e")
n = B("n")
a = A("a")
i = B("i")
f = B("f")
h = B("h")
m = A("m")
j = A("j")

c.s = j
e.p = i
n.p = i
a.s = j
i.p = n
f.p = i
h.p = i
m.s = a
j.s = a
assert n.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")
e = B("e")
n = B("n")
a = A("a")
i = B("i")
f = B("f")
h = B("h")
m = A("m")
j = A("j")

c.s = j
e.p = i
n.p = i
a.s = j
i.p = n
f.p = i
h.p = i
m.s = a
j.s = a
assert n.p.p.p.p.p.p.p.txt == "i"