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

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

e = A("e")
b = B("b")
n = A("n")
f = B("f")
i = B("i")
h = A("h")
m = A("m")

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

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

e = A("e")
b = B("b")
n = A("n")
f = B("f")
i = B("i")
h = A("h")
m = A("m")

e.p = h
e.s = h
b.v = i
n.p = e
n.s = m
f.v = b
i.v = f
h.p = m
h.s = m
m.p = h
m.s = h
assert i.v.v.v.v.v.txt == "b"