#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

typedef unsigned long long u64;

u64 gcd(u64 h, u64 l)
{
    while(l) { h%=l; if(!h)return l; l%=h; } return h;
}

int main()
{
    char buf[200];
    while(fgets(buf, 200, stdin))
    {
	char *pb=buf;
	u64 p=strtoull(pb, &pb, 0);
	u64 ph=1;
	int facts=0;
	do
	{
	    ph*=strtoull(pb, &pb, 0)-1;
	    while(*pb && isspace(*++pb));
	    ++facts;
	} while(*pb);
	u64 g=gcd(p-1, ph);
	if((g<<4) > ph)
	{
	    printf("C%i p=%llu phi=%llu (gcd=%llu) ratio=%llu/%llu\n",
		   facts, p, ph, g, (p-1)/g, ph/g);
	}
    }
}
    
	

