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 C++14 (GCC 5.4.1) (judge verdict: Time Limit Exceeded)

#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

const int dx[] = {0, -1, 0, 1};
const int dy[] = {-1, 0, 1, 0};

int h,w;
std::string m[2001];

int memox[2001][2001];
int memoy[2001][2001];

bool ok;
int dfs(int x, int y, int ix, int iy) {
    if(!IN(0,x,h) || !IN(0,y,w) || m[x][y] == '#') return 0;
    if((ix == 1 || ix == 3) && memox[x][y]) { ok = false; return memox[x][y]; }
    if((iy == 0 || iy == 2) && memoy[x][y]) { ok = false; return memoy[x][y]; }
    int res = dfs(x+dx[ix], y+dy[iy], ix, iy);
    return ok ? 1 + res : res;
}

int main(){
    INIT;
    cin >> h >> w;
    REP(i,h) {
        cin >> m[i];
    }
    int ans = 0;
    REP(i,h) {
        REP(j,w) {
            int cnt = 0;
            if(m[i][j] == '.') {
                ok = true; memox[i][j] = dfs(i+dx[1],j+dy[1],1,1);
                int resx = dfs(i+dx[3],j+dy[3],3,3);
                if(ok) memox[i][j] += resx + 1;
                ok = true; memoy[i][j] = dfs(i+dx[0],j+dy[0],0,0);
                int resy = dfs(i+dx[2],j+dy[2],2,2);
                if(ok) memoy[i][j] += resy + 1;
                cnt = memox[i][j] + memoy[i][j] - 1;
            }
            ans = std::max(ans,cnt);
        }
    }
    cout << ans << "\n";
}