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

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

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

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

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

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

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