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

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

k = A("k")
g = B("g")
a = A("a")
m = B("m")
d = B("d")
i = A("i")
h = A("h")
c = B("c")
f = B("f")

k.z = c
k.q = f
g.p = a
g.w = f
a.z = g
a.q = c
m.p = k
m.w = f
d.p = h
d.w = c
i.z = m
i.q = d
h.z = d
h.q = d
c.p = h
c.w = f
f.p = a
f.w = c
assert i.z.p.z.w.p.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.q: B = None
        self.txt = txt

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

k = A("k")
g = B("g")
a = A("a")
m = B("m")
d = B("d")
i = A("i")
h = A("h")
c = B("c")
f = B("f")

k.z = c
k.q = f
g.p = a
g.w = f
a.z = g
a.q = c
m.p = k
m.w = f
d.p = h
d.w = c
i.z = m
i.q = d
h.z = d
h.q = d
c.p = h
c.w = f
f.p = a
f.w = c
assert i.z.p.z.w.p.z.p.txt == "a"