Problem:
Score: 100 points

Problem Statement

Takahashi the Jumbo will practice golf.

His objective is to get a carry distance that is a multiple of K, while he can only make a carry distance of between A and B (inclusive).

If he can achieve the objective, print OK; if he cannot, print NG.

Constraints

All values in input are integers.

1 \leq A \leq B \leq 1000

1 \leq K \leq 1000

Input

Input is given from Standard Input in the following format:

K
A B

Output

If he can achieve the objective, print OK; if he cannot, print NG.

Sample Input 1

7
500 600

Sample Output 1

OK

Among the multiples of 7, for example, 567 lies between 500 and 600.

Sample Input 2

4
5 7

Sample Output 2

NG

No multiple of 4 lies between 5 and 7.

Sample Input 3

1
11 11

Sample Output 3

OK

Solution in Rust (1.42.0) (judge verdict: Runtime Error)

use itertools::Itertools;

fn main() {
    let (n, m, q, v) = input();
    println!("{}", solve(n, m, q, v));
}

fn input() -> (usize, usize, usize, Vec<(usize, usize, usize, usize)>) {
    let mut buf1 = String::new();
    let mut buf2 = String::new();
    
    std::io::stdin().read_line(&mut buf1).unwrap();
    std::io::stdin().read_line(&mut buf2).unwrap();
    buf1.pop();
    buf2.pop();
    let mut iter1 = buf1.split_whitespace();
    let mut iter2 = buf2.split_whitespace();

    let n: usize = iter1.next().unwrap().parse().unwrap();
    let m: usize = iter1.next().unwrap().parse().unwrap();
    let q: usize = iter2.next().unwrap().parse().unwrap();

    let mut v: Vec<(usize, usize, usize, usize)> = Vec::new();
    for _ in 0..q {
        let mut buf3 = String::new();
        std::io::stdin().read_line(&mut buf3).unwrap();
        buf3.pop();
        let mut iter3 = buf3.split_whitespace();
        let a: usize = iter3.next().unwrap().parse().unwrap();
        let b: usize = iter3.next().unwrap().parse().unwrap();
        let c: usize = iter3.next().unwrap().parse().unwrap();
        let d: usize = iter3.next().unwrap().parse().unwrap();
        v.push((a, b, c, d));
    }
    (n, m, q, v)
}

fn solve(n: usize, m: usize, q: usize, v: Vec<(usize, usize, usize, usize)>) -> usize {
    let t = (1..m+1).combinations_with_replacement(n)
            .map(|A| 
                v.iter()
                .filter(|(a, b, c, _d)| A[*b-1] - A[*a-1] == *c )
                .fold(0, |sum, (_, _, _, d)| sum + d )
            );
    t.max().unwrap()
}