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

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

a = A("a")
h = B("h")
d = A("d")
k = B("k")
n = B("n")
c = B("c")
f = B("f")
i = B("i")
j = B("j")
b = A("b")

a.w = d
a.v = k
h.p = d
h.z = c
d.w = a
d.v = h
k.p = d
k.z = c
n.p = b
n.z = f
c.p = b
c.z = f
f.p = a
f.z = c
i.p = a
i.z = k
j.p = d
j.z = k
b.w = a
b.v = k
assert c.p.w.w.v.z.p.v.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.v: B = None
        self.txt = txt

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

a = A("a")
h = B("h")
d = A("d")
k = B("k")
n = B("n")
c = B("c")
f = B("f")
i = B("i")
j = B("j")
b = A("b")

a.w = d
a.v = k
h.p = d
h.z = c
d.w = a
d.v = h
k.p = d
k.z = c
n.p = b
n.z = f
c.p = b
c.z = f
f.p = a
f.z = c
i.p = a
i.z = k
j.p = d
j.z = k
b.w = a
b.v = k
assert c.p.w.w.v.z.p.v.p.v.txt == "h"