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

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

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

i.p = d
n.y = g
k.p = i
a.y = g
e.p = d
l.y = e
g.p = k
c.y = i
d.p = i
b.y = g
assert b.y.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.y: A = None
        self.txt = txt

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

i.p = d
n.y = g
k.p = i
a.y = g
e.p = d
l.y = e
g.p = k
c.y = i
d.p = i
b.y = g
assert b.y.p.p.p.p.p.p.p.txt == "d"