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

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

e = A("e")
c = B("c")
g = B("g")
i = A("i")
h = A("h")
l = B("l")
b = A("b")
a = A("a")
f = A("f")
m = A("m")

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

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

e = A("e")
c = B("c")
g = B("g")
i = A("i")
h = A("h")
l = B("l")
b = A("b")
a = A("a")
f = A("f")
m = A("m")

e.v = h
c.p = g
g.p = c
i.v = a
h.v = b
l.p = c
b.v = m
a.v = i
f.v = h
m.v = h
assert i.v.v.v.v.v.v.v.v.v.txt == "a"