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

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

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

m.z = d
m.w = l
k.s = j
k.x = j
e.s = m
e.x = f
j.z = d
j.w = e
f.z = k
f.w = d
d.s = f
d.x = j
i.s = j
i.x = j
l.s = j
l.x = f
g.s = f
g.x = f
assert k.x.w.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.w: B = None
        self.txt = txt

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

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

m.z = d
m.w = l
k.s = j
k.x = j
e.s = m
e.x = f
j.z = d
j.w = e
f.z = k
f.w = d
d.s = f
d.x = j
i.s = j
i.x = j
l.s = j
l.x = f
g.s = f
g.x = f
assert k.x.w.x.z.txt == "k"