My Hero Academia (you) has taken a break from saving my grades and has now decided to help me with my burgeoning photography hobby. I have taken an image with my camera, but there are a few problems with it. Please help me fix it.
Specifically, I will provide you with my image, represented as a matrix of $$$n \times m$$$ integers. The edges of the matrix "loop around", meaning that the left-most column is considered adjacent to the right-most column, and the top-most row is considered adjacent to the bottom-most row. To fully process the image, we will apply $$$k$$$ transformations sequentially on the image. These transformations will be of the following form (where +x is to the right, +y is up):
Given the image and a list of $$$k$$$ operations, please be My Hero Photographia and provide me with the final image.
The first line of input contains two integers $$$n$$$ and $$$m$$$ $$$(3 \leq n, m \leq 100)$$$, the dimensions of the image. The following $$$n$$$ lines contain $$$m$$$ integers each (between $$$0$$$ and $$$100$$$ inclusive), representing the image.
The next line of input contains a single integer $$$k$$$ $$$(1 \leq k \leq 1000)$$$, the number of operations to be performed on the image. The following $$$k$$$ lines each contain a single operation to be performed on the image. Each operation is one of the following:
After performing all operations, output the resulting image.
The image should be formatted as $$$n$$$ lines, each containing $$$m$$$ integers separated by spaces, or $$$m$$$ lines, each containing $$$n$$$ integers separated by spaces (depending on the rotation of the image.
4 5 3 3 3 10 16 3 3 3 12 38 3 3 3 40 4 5 6 7 8 9 1 Blur
9 4 6 11 11 8 3 8 14 14 8 4 9 13 13 5 4 9 11 10
3 3 1 2 3 4 5 6 7 8 9 1 Shift 0 1
4 5 6 7 8 9 1 2 3
3 3 1 2 3 4 5 6 7 8 9 1 Sharpen
-99 2 3 4 5 6 7 8 109
3 4 1 2 3 4 5 6 7 8 9 10 11 12 2 Rotate CW Flip Horizontal
1 5 9 2 6 10 3 7 11 4 8 12