#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;
#define MAX 130000000
bool Sieve[MAX+1];
vector<long long> Factors;
long long N,t,b;
int ans=0;
void Fact()
{
long long i;
Factors.clear();
for (i=1;i*i<=b;i++)
{
if (!Sieve[i])
{
while (b%i==0)
{
Factors.push_back((long long)i);
b/=i;
}
}
}
if (b>1)
{
Factors.push_back(b);
}
return;
}
void Generate(int f,long long number,bool skipped_last)
{
if (f==Factors.size())
{
if (number<=t)
{
ans++;
}
return;
}
if (number>t)
return;
Generate(f+1,number,true);
if (f>0)
{
if (Factors[f]==Factors[f-1] && skipped_last)
return;
}
Generate(f+1,number*Factors[f],false);
return;
}
int main()
{
int i,j;
int test=0;
Sieve[1]=true;
for (i=2;i*i<=MAX;i++)
{
if (!Sieve[i])
{
for (j=i*i;j<=MAX;j+=i)
{
Sieve[j]=true;
}
}
}
while(!cin.eof())
{
cin>>N;
if (cin.eof())
break;
cin>>t;
cin>>b;
t%=N;
test++;
ans=0;
Fact();
Generate(0,1,false);
if (ans%2==0)
printf("Case %d: Off\n",test);
else
printf("Case %d: On\n",test);
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHZlY3Rvcj4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBNQVggMTMwMDAwMDAwCgpib29sIFNpZXZlW01BWCsxXTsKdmVjdG9yPGxvbmcgbG9uZz4gRmFjdG9yczsKCmxvbmcgbG9uZyBOLHQsYjsKaW50IGFucz0wOwoKdm9pZCBGYWN0KCkKewogICAgbG9uZyBsb25nIGk7CgogICAgRmFjdG9ycy5jbGVhcigpOwoKICAgIGZvciAoaT0xO2kqaTw9YjtpKyspCiAgICB7CiAgICAgICAgaWYgKCFTaWV2ZVtpXSkKICAgICAgICB7CiAgICAgICAgICAgIHdoaWxlIChiJWk9PTApCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIEZhY3RvcnMucHVzaF9iYWNrKChsb25nIGxvbmcpaSk7CiAgICAgICAgICAgICAgICBiLz1pOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQoKICAgIGlmIChiPjEpCiAgICB7CiAgICAgICAgRmFjdG9ycy5wdXNoX2JhY2soYik7CiAgICB9CgogICAgcmV0dXJuOwp9Cgp2b2lkIEdlbmVyYXRlKGludCBmLGxvbmcgbG9uZyBudW1iZXIsYm9vbCBza2lwcGVkX2xhc3QpCnsKICAgIGlmIChmPT1GYWN0b3JzLnNpemUoKSkKICAgIHsKICAgICAgICBpZiAobnVtYmVyPD10KQogICAgICAgIHsKICAgICAgICAgICAgYW5zKys7CiAgICAgICAgfQoKICAgICAgICByZXR1cm47CiAgICB9CgogICAgaWYgKG51bWJlcj50KQogICAgcmV0dXJuOwoKICAgIEdlbmVyYXRlKGYrMSxudW1iZXIsdHJ1ZSk7CgogICAgaWYgKGY+MCkKICAgIHsKICAgICAgICBpZiAoRmFjdG9yc1tmXT09RmFjdG9yc1tmLTFdICYmIHNraXBwZWRfbGFzdCkKICAgICAgICByZXR1cm47CiAgICB9CgogICAgR2VuZXJhdGUoZisxLG51bWJlcipGYWN0b3JzW2ZdLGZhbHNlKTsKCiAgICByZXR1cm47Cn0KCmludCBtYWluKCkKewogICAgaW50IGksajsKICAgIGludCB0ZXN0PTA7CgogICAgU2lldmVbMV09dHJ1ZTsKICAgIGZvciAoaT0yO2kqaTw9TUFYO2krKykKICAgIHsKICAgICAgICBpZiAoIVNpZXZlW2ldKQogICAgICAgIHsKICAgICAgICAgICAgZm9yIChqPWkqaTtqPD1NQVg7ais9aSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgU2lldmVbal09dHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KCiAgICB3aGlsZSghY2luLmVvZigpKQogICAgewogICAgICAgIGNpbj4+TjsKCiAgICAgICAgaWYgKGNpbi5lb2YoKSkKICAgICAgICBicmVhazsKCiAgICAgICAgY2luPj50OwogICAgICAgIGNpbj4+YjsKCiAgICAgICAgdCU9TjsKCiAgICAgICAgdGVzdCsrOwoKICAgICAgICBhbnM9MDsKICAgICAgICBGYWN0KCk7CiAgICAgICAgR2VuZXJhdGUoMCwxLGZhbHNlKTsKCiAgICAgICAgaWYgKGFucyUyPT0wKQogICAgICAgIHByaW50ZigiQ2FzZSAlZDogT2ZmXG4iLHRlc3QpOwogICAgICAgIGVsc2UKICAgICAgICBwcmludGYoIkNhc2UgJWQ6IE9uXG4iLHRlc3QpOwogICAgfQoKICAgIHJldHVybiAwOwp9Cg==