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

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

k = A("k")
h = B("h")
a = B("a")
c = B("c")
d = A("d")
e = A("e")
f = A("f")
j = A("j")

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

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

k = A("k")
h = B("h")
a = B("a")
c = B("c")
d = A("d")
e = A("e")
f = A("f")
j = A("j")

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