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

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

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

k.p = c
b.w = l
n.w = l
c.p = l
j.w = d
d.p = l
f.w = l
e.p = d
i.w = k
l.p = k
assert k.p.p.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

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

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

k.p = c
b.w = l
n.w = l
c.p = l
j.w = d
d.p = l
f.w = l
e.p = d
i.w = k
l.p = k
assert k.p.p.p.p.p.p.p.p.txt == "l"