<reponame>bossm0n5t3r/BOJ
import sys


def sol():
    # sys.stdin = open("./17069/input.txt")
    input = sys.stdin.readline
    N = int(input())
    house = [list(map(int, input().split())) for _ in range(N)]
    dp = []
    for r in range(N):
        tmp_row = []
        for c in range(N):
            tmp = [0] * 3
            tmp_row.append(tmp)
        dp.append(tmp_row)
    # 가로: 0, 세로: 1, 대각선: 2
    dp[0][1][0] = 1
    for r in range(N):
        for c in range(N):
            if dp[r][c][0] > 0:
                if c + 1 < N and house[r][c + 1] == 0:
                    dp[r][c + 1][0] += dp[r][c][0]
                if (
                    r + 1 < N
                    and c + 1 < N
                    and house[r][c + 1] == 0
                    and house[r + 1][c + 1] == 0
                    and house[r + 1][c] == 0
                ):
                    dp[r + 1][c + 1][2] += dp[r][c][0]
            if dp[r][c][1] > 0:
                if r + 1 < N and house[r + 1][c] == 0:
                    dp[r + 1][c][1] += dp[r][c][1]
                if (
                    r + 1 < N
                    and c + 1 < N
                    and house[r][c + 1] == 0
                    and house[r + 1][c + 1] == 0
                    and house[r + 1][c] == 0
                ):
                    dp[r + 1][c + 1][2] += dp[r][c][1]
            if dp[r][c][2] > 0:
                if c + 1 < N and house[r][c + 1] == 0:
                    dp[r][c + 1][0] += dp[r][c][2]
                if r + 1 < N and house[r + 1][c] == 0:
                    dp[r + 1][c][1] += dp[r][c][2]
                if (
                    r + 1 < N
                    and c + 1 < N
                    and house[r][c + 1] == 0
                    and house[r + 1][c + 1] == 0
                    and house[r + 1][c] == 0
                ):
                    dp[r + 1][c + 1][2] += dp[r][c][2]
    print(sum(dp[N - 1][N - 1]))


if __name__ == "__main__":
    sol()

import sys


def sol():
    # sys.stdin = open("./17069/input.txt")
    input = sys.stdin.readline
    N = int(input())
    house = [list(map(int, input().split())) for _ in range(N)]
    dp = []
    for r in range(N):
        tmp_row = []
        for c in range(N):
            tmp = [0] * 3
            tmp_row.append(tmp)
        dp.append(tmp_row)
    # 가로: 0, 세로: 1, 대각선: 2
    dp[0][1][0] = 1
    for r in range(N):
        for c in range(N):
            if dp[r][c][0] > 0:
                if c + 1 < N and house[r][c + 1] == 0:
                    dp[r][c + 1][0] += dp[r][c][0]
                if (
                    r + 1 < N
                    and c + 1 < N
                    and house[r][c + 1] == 0
                    and house[r + 1][c + 1] == 0
                    and house[r + 1][c] == 0
                ):
                    dp[r + 1][c + 1][2] += dp[r][c][0]
            if dp[r][c][1] > 0:
                if r + 1 < N and house[r + 1][c] == 0:
                    dp[r + 1][c][1] += dp[r][c][1]
                if (
                    r + 1 < N
                    and c + 1 < N
                    and house[r][c + 1] == 0
                    and house[r + 1][c + 1] == 0
                    and house[r + 1][c] == 0
                ):
                    dp[r + 1][c + 1][2] += dp[r][c][1]
            if dp[r][c][2] > 0:
                if c + 1 < N and house[r][c + 1] == 0:
                    dp[r][c + 1][0] += dp[r][c][2]
                if r + 1 < N and house[r + 1][c] == 0:
                    dp[r + 1][c][1] += dp[r][c][2]
                if (
                    r + 1 < N
                    and c + 1 < N
                    and house[r][c + 1] == 0
                    and house[r + 1][c + 1] == 0
                    and house[r + 1][c] == 0
                ):
                    dp[r + 1][c + 1][2] += dp[r][c][2]
    print(sum(dp[N - 1][N - 1]))


if __name__ == "__main__":
    sol()
# sys.stdin = open("./17069/input.txt") # 가로: 0, 세로: 1, 대각선: 2