Problem: Warawreh created a great company called Nanosoft. The only thing that Warawreh still has to do is to place a large picture containing its logo on top of the company's building.

The logo of Nanosoft can be described as four squares of the same size merged together into one large square. The top left square is colored with red, the top right square is colored with green, the bottom left square is colored with yellow and the bottom right square is colored with blue.

An Example of some correct logos:

<image>

An Example of some incorrect logos:

<image>

Warawreh went to Adhami's store in order to buy the needed picture. Although Adhami's store is very large he has only one picture that can be described as a grid of n rows and m columns. The color of every cell in the picture will be green (the symbol 'G'), red (the symbol 'R'), yellow (the symbol 'Y') or blue (the symbol 'B').

Adhami gave Warawreh q options, in every option he gave him a sub-rectangle from that picture and told him that he can cut that sub-rectangle for him. To choose the best option, Warawreh needs to know for every option the maximum area of sub-square inside the given sub-rectangle that can be a Nanosoft logo. If there are no such sub-squares, the answer is 0.

Warawreh couldn't find the best option himself so he asked you for help, can you help him?

Input

The first line of input contains three integers n, m and q (1 ≤ n , m ≤ 500, 1 ≤ q ≤ 3 ⋅ 10^{5}) — the number of row, the number columns and the number of options.

For the next n lines, every line will contain m characters. In the i-th line the j-th character will contain the color of the cell at the i-th row and j-th column of the Adhami's picture. The color of every cell will be one of these: {'G','Y','R','B'}.

For the next q lines, the input will contain four integers r_1, c_1, r_2 and c_2 (1 ≤ r_1 ≤ r_2 ≤ n, 1 ≤ c_1 ≤ c_2 ≤ m). In that option, Adhami gave to Warawreh a sub-rectangle of the picture with the upper-left corner in the cell (r_1, c_1) and with the bottom-right corner in the cell (r_2, c_2).

Output

For every option print the maximum area of sub-square inside the given sub-rectangle, which can be a NanoSoft Logo. If there are no such sub-squares, print 0.

Examples

Input


5 5 5
RRGGB
RRGGY
YYBBG
YYBBR
RBBRG
1 1 5 5
2 2 5 5
2 2 3 3
1 1 3 5
4 4 5 5


Output


16
4
4
4
0


Input


6 10 5
RRRGGGRRGG
RRRGGGRRGG
RRRGGGYYBB
YYYBBBYYBB
YYYBBBRGRG
YYYBBBYBYB
1 1 6 10
1 3 3 10
2 2 6 6
1 7 6 10
2 1 5 10


Output


36
4
16
16
16


Input


8 8 8
RRRRGGGG
RRRRGGGG
RRRRGGGG
RRRRGGGG
YYYYBBBB
YYYYBBBB
YYYYBBBB
YYYYBBBB
1 1 8 8
5 2 5 7
3 1 8 6
2 3 5 8
1 2 6 8
2 1 5 5
2 1 7 7
6 5 7 5


Output


64
0
16
4
16
4
36
0

Note

Picture for the first test:

<image>

The pictures from the left to the right corresponds to the options. The border of the sub-rectangle in the option is marked with black, the border of the sub-square with the maximal possible size, that can be cut is marked with gray.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
using ld = long double;
template <typename T>
using mat = vector<vector<T>>;
template <int mod>
struct modint {
  int x;
  modint() : x(0) {}
  modint(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  modint &operator+=(const modint &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  modint &operator-=(const modint &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  modint &operator*=(const modint &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  modint &operator/=(const modint &p) {
    *this *= p.inverse();
    return *this;
  }
  modint operator-() const { return modint(-x); }
  modint operator+(const modint &p) const { return modint(*this) += p; }
  modint operator-(const modint &p) const { return modint(*this) -= p; }
  modint operator*(const modint &p) const { return modint(*this) *= p; }
  modint operator/(const modint &p) const { return modint(*this) /= p; }
  bool operator==(const modint &p) const { return x == p.x; }
  bool operator!=(const modint &p) const { return x != p.x; }
  modint inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return modint(u);
  }
  modint pow(int64_t n) const {
    modint ret(1), mul(x);
    while (n > 0) {
      if (n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  friend ostream &operator<<(ostream &os, const modint &p) { return os << p.x; }
  friend istream &operator>>(istream &is, modint &a) {
    int64_t t;
    is >> t;
    a = modint<mod>(t);
    return (is);
  }
  static int get_mod() { return mod; }
};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
T mypow(T x, ll n) {
  T ret = 1;
  while (n > 0) {
    if (n & 1) (ret *= x);
    (x *= x);
    n >>= 1;
  }
  return ret;
}
ll modpow(ll x, ll n, const ll mod) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) (ret *= x);
    (x *= x);
    n >>= 1;
    x %= mod;
    ret %= mod;
  }
  return ret;
}
uint64_t my_rand(void) {
  static uint64_t x = 88172645463325252ULL;
  x = x ^ (x << 13);
  x = x ^ (x >> 7);
  return x = x ^ (x << 17);
}
template <typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T>
using Edges = vector<edge<T>>;
template <typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
const long double eps = 0.001;
const long double PI = 3.141592653589793;
int n, m, q;
bool check(int x, int y, int r, vector<string> &grid) {
  if (x - r >= 0 && x + r <= n && y + r <= m && y - r >= 0) {
    for (int dx = (-r), max_i = (0); dx < max_i; dx++) {
      int ny = y - r;
      int nx = x + dx;
      if (grid[nx][ny] != 'R') return false;
    }
    for (int dy = (-r), max_i = (0); dy < max_i; dy++) {
      int ny = y + dy;
      int nx = x - r;
      if (grid[nx][ny] != 'R') return false;
    }
    for (int dx = (-r), max_i = (0); dx < max_i; dx++) {
      int ny = y + r - 1;
      int nx = x + dx;
      if (grid[nx][ny] != 'G') return false;
    }
    for (int dy = (0), max_i = (r); dy < max_i; dy++) {
      int ny = y + dy;
      int nx = x - r;
      if (grid[nx][ny] != 'G') return false;
    }
    for (int dx = (0), max_i = (r); dx < max_i; dx++) {
      int ny = y - r;
      int nx = x + dx;
      if (grid[nx][ny] != 'Y') return false;
    }
    for (int dy = (-r), max_i = (0); dy < max_i; dy++) {
      int ny = y + dy;
      int nx = x + r - 1;
      if (grid[nx][ny] != 'Y') return false;
    }
    for (int dx = (0), max_i = (r); dx < max_i; dx++) {
      int ny = y + r - 1;
      int nx = x + dx;
      if (grid[nx][ny] != 'B') return false;
    }
    for (int dy = (0), max_i = (r); dy < max_i; dy++) {
      int ny = y + dy;
      int nx = x + r - 1;
      if (grid[nx][ny] != 'B') return false;
    }
  }
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << setprecision(20);
  cin >> n >> m >> q;
  vector<string> grid(n);
  for (int i = (0), max_i = (n); i < max_i; i++) cin >> grid[i];
  mat<pair<int, int>> rects(n / 2 + 1);
  for (int i = (0), max_i = (n + 1); i < max_i; i++)
    for (int j = (0), max_i = (m + 1); j < max_i; j++) {
      rects[0].emplace_back(make_pair(i, j));
    }
  for (int r = (1), max_i = (n / 2 + 1); r < max_i; r++) {
    for (auto p : rects[r - 1]) {
      int x = p.first, y = p.second;
      if (x - r >= 0 && x + r <= n && y + r <= m && y - r >= 0) {
        if (check(x, y, r, grid)) rects[r].emplace_back(make_pair(x, y));
      }
    }
  }
  vector<mat<int>> cumsums(n / 2 + 1, mat<int>(n + 2, vector<int>(m + 2)));
  for (int r = (0), max_i = (n / 2 + 1); r < max_i; r++) {
    for (auto p : rects[r]) {
      cumsums[r][p.first + 1][p.second + 1]++;
    }
  }
  for (int r = (0), max_i = (n / 2 + 1); r < max_i; r++) {
    for (int x = (0), max_i = (n + 1); x < max_i; x++) {
      for (int y = (0), max_i = (m + 1); y < max_i; y++)
        cumsums[r][x][y + 1] += cumsums[r][x][y];
    }
    for (int x = (0), max_i = (n + 1); x < max_i; x++) {
      for (int y = (0), max_i = (m + 2); y < max_i; y++)
        cumsums[r][x + 1][y] += cumsums[r][x][y];
    }
  }
  for (int _ = (0), max_i = (q); _ < max_i; _++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    for (int r = min(c - a + 1, d - b + 1) / 2 + 1 - 1; r >= 0; r--) {
      if (cumsums[r][c + 2 - r][d + 2 - r] + cumsums[r][a + r][b + r] -
          cumsums[r][c + 2 - r][b + r] - cumsums[r][a + r][d + 2 - r]) {
        cout << r * r * 4 << '\n';
        break;
      }
    }
  }
}