#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 27);
bool f[N + 1];
vector<int> prime;
void siv() {
prime.push_back(2);
for (int i = 3; i * i <= N; i += 2) {
if (!f[i]) {
for (int j = i * i; j <= N; j += i) {
f[j] = 1;
}
}
}
for (int i = 3; i <= N; i += 2)
if (!f[i])
prime.push_back(i);
}
char ans[][5] = { "Off", "On" };
bool fact(long long x, long long y) {
vector<long long> indx;
for (int i = 0; prime[i] * prime[i] <= x && i < prime.size(); ++i) {
while (x % prime[i] == 0) {
x /= prime[i];
indx.push_back(prime[i]);
}
}
if (x > 1)
indx.push_back(x);
set<long long> ans;
long long l = indx.size(), p;
for (long long i = 0; i <= (1LL << l); ++i) {
p = 1;
for (long long j = 0; p <= y && j < l; ++j)
if ((1 << j) & i)
p *= indx[j];
if (p <= y)
ans.insert(p);
}
return ans.size() % 2;
}
int main(int argc, char **argv) {
#ifndef ONLINE_JUDGE
freopen("a.in", "r", stdin);
#endif
siv();
long long a, b, c;
while (scanf("%lld %lld %lld", &a, &b, &c) > 0) {
b %= a;
static int cas = 1;
printf("Case %d: %s\n", cas++, ans[fact(c, b)]);
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmNvbnN0IGludCBOID0gKDEgPDwgMjcpOwpib29sIGZbTiArIDFdOwp2ZWN0b3I8aW50PiBwcmltZTsKdm9pZCBzaXYoKSB7CglwcmltZS5wdXNoX2JhY2soMik7Cglmb3IgKGludCBpID0gMzsgaSAqIGkgPD0gTjsgaSArPSAyKSB7CgkJaWYgKCFmW2ldKSB7CgkJCWZvciAoaW50IGogPSBpICogaTsgaiA8PSBOOyBqICs9IGkpIHsKCQkJCWZbal0gPSAxOwoJCQl9CgkJfQoJfQoJZm9yIChpbnQgaSA9IDM7IGkgPD0gTjsgaSArPSAyKQoJCWlmICghZltpXSkKCQkJcHJpbWUucHVzaF9iYWNrKGkpOwoKfQpjaGFyIGFuc1tdWzVd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