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

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

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

k.o = n
f.p = g
g.p = e
a.o = k
i.p = g
b.o = a
d.p = i
n.o = k
e.p = d
assert i.p.p.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

k.o = n
f.p = g
g.p = e
a.o = k
i.p = g
b.o = a
d.p = i
n.o = k
e.p = d
assert i.p.p.p.p.p.p.p.txt == "d"