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

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

l = A("l")
h = B("h")
e = A("e")
c = B("c")
d = B("d")
n = B("n")
j = A("j")
i = A("i")

l.p = d
h.v = d
e.p = h
c.v = h
d.v = c
n.v = h
j.p = h
i.p = n
assert j.p.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

l = A("l")
h = B("h")
e = A("e")
c = B("c")
d = B("d")
n = B("n")
j = A("j")
i = A("i")

l.p = d
h.v = d
e.p = h
c.v = h
d.v = c
n.v = h
j.p = h
i.p = n
assert j.p.v.v.v.txt == "h"