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

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

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

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

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

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

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