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

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

g = A("g")
b = B("b")
l = A("l")
e = A("e")
a = B("a")
k = B("k")
d = A("d")
n = B("n")

g.w = b
g.q = k
b.p = a
l.w = a
l.q = a
e.w = a
e.q = n
a.p = n
k.p = n
d.w = n
d.q = a
n.p = k
assert k.p.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.q: B = None
        self.txt = txt

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

g = A("g")
b = B("b")
l = A("l")
e = A("e")
a = B("a")
k = B("k")
d = A("d")
n = B("n")

g.w = b
g.q = k
b.p = a
l.w = a
l.q = a
e.w = a
e.q = n
a.p = n
k.p = n
d.w = n
d.q = a
n.p = k
assert k.p.p.p.p.p.p.p.txt == "n"