In the world of
Cyberpunk, all paintings are done by using lasers. As a
cyber painter, painting with lasers is your daily job.
You have a laser painting board with $n$ rows and $m$ columns of laser emitters. The distance between rows is $1$, and so is the distance between columns. Each laser emitter can emit a laser with a length of $0.5$ in four directions. Specifically, you can set an integer between $0$ and $15$ as the state value for each laser emitter, which can be denoted by a four-bit binary number $(X_1X_2X_3X_4)_2$ (For example, $11=(1011)_2$). The meaning of the state value is as follows:
- $X_1=1$: The laser emitter emits a laser of length $0.5$ in the upward direction.
- $X_2=1$: The laser emitter emits a laser of length $0.5$ in the right direction.
- $X_3=1$: The laser emitter emits a laser of length $0.5$ in the downward direction.
- $X_4=1$: The laser emitter emits a laser of length $0.5$ in the left direction.
Given $n \times m$ integers between $0$ and $15$, you need to assign an integer to each laser emitter as its state value. You are curious about the expectation of the number of squares that can be formed by the laser if the $n \times m$ integers are assigned uniformly at random, where the squares can be of arbitrary edge length.