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

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

i = A("i")
n = B("n")
m = A("m")
j = A("j")
c = B("c")
f = B("f")
g = B("g")
b = B("b")

i.s = m
i.x = m
n.z = j
n.w = f
m.s = i
m.x = j
j.s = i
j.x = i
c.z = m
c.w = n
f.z = j
f.w = c
g.z = i
g.w = f
b.z = m
b.w = c
assert f.w.z.x.x.s.s.x.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.x: A = None
        self.txt = txt

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

i = A("i")
n = B("n")
m = A("m")
j = A("j")
c = B("c")
f = B("f")
g = B("g")
b = B("b")

i.s = m
i.x = m
n.z = j
n.w = f
m.s = i
m.x = j
j.s = i
j.x = i
c.z = m
c.w = n
f.z = j
f.w = c
g.z = i
g.w = f
b.z = m
b.w = c
assert f.w.z.x.x.s.s.x.txt == "m"