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

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

e = A("e")
h = B("h")
f = B("f")
l = B("l")
a = A("a")
i = A("i")
k = A("k")
g = B("g")
j = B("j")

e.w = l
h.p = e
f.p = a
l.p = i
a.w = f
i.w = l
k.w = f
g.p = k
j.p = e
assert g.p.w.p.w.p.w.p.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

e = A("e")
h = B("h")
f = B("f")
l = B("l")
a = A("a")
i = A("i")
k = A("k")
g = B("g")
j = B("j")

e.w = l
h.p = e
f.p = a
l.p = i
a.w = f
i.w = l
k.w = f
g.p = k
j.p = e
assert g.p.w.p.w.p.w.p.w.p.txt == "a"