# 俄羅斯方塊
## hint
```python=
def check(...):
for x, y in chosen_shape:
# 檢查x, y 是否超出邊界
if ...: return False
if ...: return False
# 檢查欲放入方塊位置是否已被填滿
if board[x][y]: return False
return True
def clear(board):
# 從桌面的最後檢查是否全部填滿
while ...:
if sum(...):
# 如果填滿就踢出(pop)並在前面補上(insert)
...
def fall(board, chpos):
# 依次把選中的形狀往下一格直到觸底或是遇到其他方塊
move = 1
while check(...): move+=1
for x,y in chosen_shape:
# 更新桌面
board[x+move-1][y] = 1
# step 1 建立桌面以及俄羅斯方塊位置
m = int(input())
n = int(input())
board = [[0]*m for _ in range(n)]
chess = {
"I":[(0,0), (1,0), (2,0), (3,0)],
"J":[(2,0), (0,1), (1,1), (2,1)],
...
}
while True:
try:
#step 2 確認擺放位置是否超出範圍
if not check(...):
print("Game Over!")
break
#step 3 紀錄選中的方塊要向左或右移動幾步
move = 0
for c in left_or_right:
#step 4 確認往右往左擺放位置是否成功,如果成功就紀錄,如果撞到東西就留在原地
if c == "right":
if check(...): move+=1
else:
if check(...): move-=1
#step 4 把選中的方塊向左或右移動
...
#step 5 使方塊下降到最下面
fall(...)
#step 6 清除存在的橫排
clear(...)
except EOFError:
for brd in board:
for b in brd:
print("*" if b else "O", end="")
print()
break
```