A JavaScript solution
\n/**\n * @param {number[][]} grid\n * @return {number}\n */\nvar maxTrailingZeros = function(g) {\n    const m = g.length;\n    const n = g[0].length;\n    con
```\n/**\n * @param {number[][]} grid\n * @return {number}\n */\nvar maxTrailingZeros = function(g) {\n    const m = g.length;\n    const n = g[0].length;\n    const ta = [...Array(m)].map(i => Array(n).fill(1));\n    const tb = [...Array(m)].map(i => Array(n).fill(1));\n    const tc = [...Array(m)].map(i => Array(n).fill(1));\n    const td = [...Array(m)].map(i => Array(n).fill(1));\n    \n    const c52 = (s) => {\n        let c5 = 0;\n        let c2 = 0;\n        while (s % 2 === 0) {\n            s = s / 2;\n            c2++;\n        }\n        while (s % 5 === 0) {\n            s = s / 5;\n            c5++;\n        }\n        return [c5, c2];\n    }\n    \n    const c10 = ([c5, c2]) => {\n        return Math.min(c5, c2);\n    }\n    \n    for (let i = 0; i < m; i++) {\n        for (let j = 0; j < n; j++) {\n            ta[i][j] = (j === 0) ? c52(g[i][j]) : [c52(g[i][j])[0] + ta[i][j-1][0], c52(g[i][j])[1] + ta[i][j-1][1]];\n            tb[i][j] = (i === 0) ? c52(g[i][j]) :  [c52(g[i][j])[0] + tb[i-1][j][0], c52(g[i][j])[1] + tb[i-1][j][1]];\n        }\n    }\n    \n    for (let i = m-1; i >= 0; i--) {\n        for (let j = n-1; j >= 0; j--) {\n            tc[i][j] = (j === n-1) ? c52(g[i][j]) : [c52(g[i][j])[0] + tc[i][j+1][0], c52(g[i][j])[1] + tc[i][j+1][1]];  // : ctz(hg(g[i][j]) * tc[i][j+1][0], tc[i][j+1][1]); // hg(g[i][j]) * tc[i][j+1];\n            td[i][j] = (i === m-1) ? c52(g[i][j]) : [c52(g[i][j])[0] + td[i+1][j][0], c52(g[i][j])[1] + td[i+1][j][1]]; // : ctz(hg(g[i][j]) * td[i+1][j][0], td[i+1][j][1]); // hg(g[i][j]) * td[i+1][j];\n        }\n    }\n    \n    let ret = 0;\n    for (let i = 0; i < m; i++) {\n        for (let j = 0; j < n; j++) {\n            let s1 = i === 0 ? c10(ta[i][j]) : c10([ta[i][j][0] + tb[i-1][j][0], ta[i][j][1] + tb[i-1][j][1]]);\n            let s2 = i === m - 1 ? c10(ta[i][j]) : c10([ta[i][j][0] + td[i+1][j][0], ta[i][j][1] + td[i+1][j][1]]);            \n            let s3 = i === 0 ? c10(tc[i][j]) : c10([tc[i][j][0] + tb[i-1][j][0], tc[i][j][1] + tb[i-1][j][1]]);\n            let s4 = i === m - 1 ? c10(tc[i][j]) : c10([tc[i][j][0] + td[i+1][j][0], tc[i][j][1] + td[i+1][j][1]]); \n            ret = Math.max(ret, s1, s2, s3, s4);\n        }\n    }\n    return ret;\n};\n```
['JavaScript']