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

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

f = A("f")
m = B("m")
a = A("a")
b = A("b")
k = A("k")
g = A("g")
l = B("l")
d = A("d")
j = A("j")
i = B("i")

f.y = g
f.p = i
m.p = j
a.y = d
a.p = i
b.y = g
b.p = i
k.y = a
k.p = i
g.y = f
g.p = i
l.p = b
d.y = b
d.p = m
j.y = f
j.p = i
i.p = k
assert f.p.p.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.p: B = None
        self.txt = txt

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

f = A("f")
m = B("m")
a = A("a")
b = A("b")
k = A("k")
g = A("g")
l = B("l")
d = A("d")
j = A("j")
i = B("i")

f.y = g
f.p = i
m.p = j
a.y = d
a.p = i
b.y = g
b.p = i
k.y = a
k.p = i
g.y = f
g.p = i
l.p = b
d.y = b
d.p = m
j.y = f
j.p = i
i.p = k
assert f.p.p.p.p.p.p.p.p.txt == "k"