Problem:
Score : 400 points

Problem Statement

There is a grid with H horizontal rows and W vertical columns, and there are obstacles on some of the squares.

Snuke is going to choose one of the squares not occupied by an obstacle and place a lamp on it.
The lamp placed on the square will emit straight beams of light in four cardinal directions: up, down, left, and right.
In each direction, the beam will continue traveling until it hits a square occupied by an obstacle or it hits the border of the grid. It will light all the squares on the way, including the square on which the lamp is placed, but not the square occupied by an obstacle.

Snuke wants to maximize the number of squares lighted by the lamp.

You are given H strings S_i (1 \leq i \leq H), each of length W. If the j-th character (1 \leq j \leq W) of S_i is #, there is an obstacle on the square at the i-th row from the top and the j-th column from the left; if that character is ., there is no obstacle on that square.

Find the maximum possible number of squares lighted by the lamp.

Constraints

1 \leq H \leq 2,000

1 \leq W \leq 2,000

S_i is a string of length W consisting of # and ..

. occurs at least once in one of the strings S_i (1 \leq i \leq H).

Input

Input is given from Standard Input in the following format:

H W
S_1
:
S_H

Output

Print the maximum possible number of squares lighted by the lamp.

Sample Input 1

4 6
#..#..
.....#
....#.
#.#...

Sample Output 1

8

If Snuke places the lamp on the square at the second row from the top and the second column from the left, it will light the following squares: the first through fifth squares from the left in the second row, and the first through fourth squares from the top in the second column, for a total of eight squares.

Sample Input 2

8 8
..#...#.
....#...
##......
..###..#
...#..#.
##....#.
#...#...
###.#..#

Sample Output 2

13

Solution in PyPy3 (2.4.0) (judge verdict: Time Limit Exceeded)

# これ愚直じゃダメなのかな
# 上下左右それぞれのテーブルを用意し、いまいるところより上/下/左/右にいくつあるかをセーブする（自分は含まない）

h, w = map(int, input().split())
table = []
for _ in range(h):
    table.append(list(input()))
top_table = [[0 for _ in range(h)] for _ in range(w)]  # 自分より上 あとで転置
bottom_table = [[0 for _ in range(h)] for _ in range(w)]  # 自分より下 あとで転置
left_table = [[0 for _ in range(w)] for _ in range(h)]  # 自分より左
right_table = [[0 for _ in range(w)] for _ in range(h)]  # 自分より右

for y in range(h):
    forward_right = [0 for _ in range(w)]
    forward_left = [0 for _ in range(w)]
    for x in range(w):
        if table[y][x] == "#":
            forward_left[x] = -1  # リセット
            continue
        elif table[y][x] == ".":
            # 番兵とか置いてないので...
            if x == 0:
                forward_left[x] = 0
            else:
                forward_left[x] = forward_left[x - 1] + 1
    for x in range(w - 1, -1, -1):
        if table[y][x] == "#":
            forward_right[x] = -1
            continue
        elif table[y][x] == ".":
            if x == w - 1:
                forward_right[x] = 0
            else:
                forward_right[x] = forward_right[x + 1] + 1

    left_table[y] = list(map(lambda x: 0 if x == -1 else x, forward_left))
    right_table[y] = list(map(lambda x: 0 if x == -1 else x, forward_right))

# print("左右")
# for y in range(h):
#     print(left_table[y], right_table[y])


for x in range(w):
    forward_top = [0 for _ in range(h)]
    forward_bottom = [0 for _ in range(h)]
    for y in range(h):
        if table[y][x] == "#":
            forward_top[y] = -1
            continue
        elif table[y][x] == ".":
            # 毎度おなじみ番兵とか置いてないので
            if y == 0:
                forward_top[y] = 0
            else:
                forward_top[y] = forward_top[y - 1] + 1
    for y in range(h - 1, -1, -1):
        if table[y][x] == "#":
            forward_bottom[y] = -1
            continue
        elif table[y][x] == ".":
            # 毎度おなじみ番兵とか置いてないので
            if y == h-1:
                forward_bottom[y] = 0
            else:
                forward_bottom[y] = forward_bottom[y + 1] + 1
    top_table[x] = list(map(lambda x: 0 if x == -1 else x, forward_top))
    bottom_table[x] = list(map(lambda x: 0 if x == -1 else x, forward_bottom))

# 転置
top_table = list(zip(*top_table))
bottom_table = list(zip(*bottom_table))

# print("上下")
# for y in range(h):
#     print(top_table[y], bottom_table[y])

# 探索
ans = 0
for y in range(h):
    for x in range(w):
        if table[y][x] == ".":
            # 最後に自分自身の場所を加える
            ans = max(ans, top_table[y][x] + bottom_table[y]
                      [x] + left_table[y][x] + right_table[y][x] + 1)

print(ans)