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

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

j = A("j")
l = B("l")
f = A("f")
b = A("b")
a = A("a")
n = B("n")
m = A("m")
c = A("c")

j.z = m
j.w = n
l.w = b
f.z = m
f.w = n
b.z = j
b.w = n
a.z = b
a.w = l
n.w = c
m.z = c
m.w = n
c.z = b
c.w = l
assert f.z.z.w.w.z.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.w: B = None
        self.txt = txt

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

j = A("j")
l = B("l")
f = A("f")
b = A("b")
a = A("a")
n = B("n")
m = A("m")
c = A("c")

j.z = m
j.w = n
l.w = b
f.z = m
f.w = n
b.z = j
b.w = n
a.z = b
a.w = l
n.w = c
m.z = c
m.w = n
c.z = b
c.w = l
assert f.z.z.w.w.z.w.w.txt == "c"