#include<bits/stdc++.h> usingnamespace std; template <classT> inlinevoidread(T &x){ x = 0; int c = getchar(), f = 1; for (; !isdigit(c); c = getchar()) if (c == 45) f = -1; for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0'); } int n, m, mx1, mx2, a[2005][2005]; int s[2005][2005], t[2005][2005], l[2005][2005]; intmain(){ read(n), read(m); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) read(a[i][j]), s[i][j] = t[i][j] = j, l[i][j] = 1; for (int i = 1; i <= n; i++) { for (int j = 2; j <= m; j++) if (a[i][j]^a[i][j-1]) s[i][j] = s[i][j-1]; for (int j = m-1; j; j--) if (a[i][j]^a[i][j+1]) t[i][j] = t[i][j+1]; } for (int i = 2; i <= n; i++) for (int j = 1; j <= m; j++) if (a[i][j]^a[i-1][j]) l[i][j] += l[i-1][j], s[i][j] = max(s[i][j], s[i-1][j]), t[i][j] = min(t[i][j], t[i-1][j]); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) { int r = l[i][j], c = t[i][j]-s[i][j]+1; mx1 = max(mx1, min(r, c)*min(r, c)); mx2 = max(mx2, r*c); } returnprintf("%d\n%d\n", mx1, mx2), 0; }