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

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

l = A("l")
d = B("d")
a = A("a")
g = A("g")
h = B("h")
e = B("e")
j = A("j")
k = A("k")
m = A("m")

l.p = d
d.v = j
d.x = h
a.p = h
g.p = h
h.v = l
h.x = d
e.v = m
e.x = d
j.p = e
k.p = h
m.p = h
assert e.v.p.x.x.v.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

l = A("l")
d = B("d")
a = A("a")
g = A("g")
h = B("h")
e = B("e")
j = A("j")
k = A("k")
m = A("m")

l.p = d
d.v = j
d.x = h
a.p = h
g.p = h
h.v = l
h.x = d
e.v = m
e.x = d
j.p = e
k.p = h
m.p = h
assert e.v.p.x.x.v.p.x.txt == "h"