Problem:
Score : 700 points

Problem Statement

We have a grid with H rows and W columns of squares.
We will represent the square at the i-th row from the top and j-th column from the left as (i,\ j).
Also, we will define the distance between the squares (i_1,\ j_1) and (i_2,\ j_2) as |i_1 - i_2| + |j_1 - j_2|.

Snuke is painting each square in red, yellow, green or blue.
Here, for a given positive integer d, he wants to satisfy the following condition:

No two squares with distance exactly d have the same color.

Find a way to paint the squares satisfying the condition.
It can be shown that a solution always exists.

Constraints

2 ≤ H, W ≤ 500

1 ≤ d ≤ H + W - 2

Input

Input is given from Standard Input in the following format:

H W d

Output

Print a way to paint the squares satisfying the condition, in the following format. If the square (i,\ j) is painted in red, yellow, green or blue, c_{ij} should be R, Y, G or B, respectively.

c_{11}c_{12}...c_{1W}
:
c_{H1}c_{H2}...c_{HW}

Sample Input 1

2 2 1

Sample Output 1

RY
GR

There are four pairs of squares with distance exactly 1.
As shown below, no two such squares have the same color.

(1,\ 1), (1,\ 2) : R, Y

(1,\ 2), (2,\ 2) : Y, R

(2,\ 2), (2,\ 1) : R, G

(2,\ 1), (1,\ 1) : G, R

Sample Input 2

2 3 2

Sample Output 2

RYB
RGB

There are six pairs of squares with distance exactly 2.
As shown below, no two such squares have the same color.

(1,\ 1) , (1,\ 3) : R , B

(1,\ 3) , (2,\ 2) : B , G

(2,\ 2) , (1,\ 1) : G , R

(2,\ 1) , (2,\ 3) : R , B

(2,\ 3) , (1,\ 2) : B , Y

(1,\ 2) , (2,\ 1) : Y , R

Solution in Rust (1.15.1) (judge verdict: Wrong Answer)

/// Thank you tanakh!!!
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input!(h: usize, w: usize, d: usize);

    let mut centers = vec![];
    let t = cmp::max(h, w) * 3 / d;
    let mut cur_si = -(cmp::max(h, w) as i64) - 1;
    let mut cur_sj = cur_si;
    let mut base_color = 0;
    for _ in 0..t {
        let d = d as i64;
        cur_si -= d - 1;
        cur_sj += d;
        if cur_si + d <= 0 {
            cur_si += d;
            cur_sj += d - 1;
        }
        let mut cur_i = cur_si;
        let mut cur_j = cur_sj;
        let mut tmp_color = 0;
        for _ in 0..t {
            let color = base_color * 2 + tmp_color;
            centers.push((cur_i, cur_j, color));
            cur_i += d;
            cur_j += d - 1;
            tmp_color = tmp_color ^ 1;
        }
        base_color = base_color ^ 1;
    }

    // println!("{:?}", centers);

    let mut ans = vec![vec![0; w]; h];
    for &(i, j, color) in centers.iter() {
        let tmp: Vec<i64> = vec![-1, 1];
        let d = d as i64;
        for dd in 0..d {
            for &t1 in tmp.iter() {
                for &t2 in tmp.iter() {
                    let h = h as i64;
                    let w = w as i64;
                    let i = i + t1 * ((d - 1) - dd);
                    let j = j + t2 * dd;
                    if i >= 0 && j >= 0 && i < h && j < w {
                        ans[i as usize][j as usize] = color;
                    }
                }
            }
        }
    }

    // println!("{:?}", ans);

    let c: Vec<char> = vec!['R', 'Y', 'B', 'G'];

    for i in 0..h {
        for j in 0..w {
            print!("{}", c[ans[i][j]]);
        }
        println!();
    }
}

// fn eliminate(ok: &mut Vec<Vec<Vec<bool>>>, color: usize, i: i64, j: i64, d: i64) {
//     let h = ok[color].len() as i64;
//     let w = ok[color][0].len() as i64;

//     let mut cur_i = i - d;
//     let mut cur_j = j;
//     while cur_i <= i as usize {
//         if cur_i >= 0 && cur_i < h && cur_j >= 0 && cur_j < w {
//             ok[cur_i as usize][cur_j as usize] = false;
//         }
//         cur_i += 1;
//         cur_j += 1;
//     }

//     let mut cur_i = i + d;
//     let mut cur_j = j;
//     while cur_i >= i as usize {
//         if cur_i >= 0 && cur_i < h && cur_j >= 0 && cur_j < w {
//             ok[cur_i as usize][cur_j as usize] = false;
//         }
//         cur_i -= 1;
//         cur_j += 1;
//     }

//     let mut cur_i = i - d;
//     let mut cur_j = j;
//     while cur_i <= i as usize {
//         if cur_i >= 0 && cur_i < h && cur_j >= 0 && cur_j < w {
//             ok[cur_i as usize][cur_j as usize] = false;
//         }
//         cur_i += 1;
//         cur_j -= 1;
//     }

//     let mut cur_i = i + d;
//     let mut cur_j = j;
//     while cur_i >= i as usize {
//         if cur_i >= 0 && cur_i < h && cur_j >= 0 && cur_j < w {
//             ok[cur_i as usize][cur_j as usize] = false;
//         }
//         cur_i -= 1;
//         cur_j -= 1;
//     }
// }