// File: /workspace/github_cpp_makefile_star2_O1/asd00012334[P]Abstract-Algebra-2018/main.cpp
// Function: main
int main(){
    using namespace std;
    using namespace prime;

    buildPrimeList();
    Polynomial<IntType,int> fint;
    Polynomial<quotient::FracType,quotient::fraction> fq;
    fint.canonicalType.scalar = &intType;
    fq.canonicalType.scalar = &quotient::fracType;

    cin>>fq;
    //fq = fq / gcd(fq.diff(),fq);
    fq.reduce();
    fint = fq.toIntCoef();
    std::cout << fint <<"\n";

    auto table = SplitDegree(fint,20000);
    for(auto e: table)
        cout<<e.first<<": "<<e.second<<"\n";

    int order = 0;
    for(auto &e: table) order += e.second;
    std::cout<<"Order: "<<order<<"\n";
    auto subS5List = loader();
    queue<int> orderMatch;
    int best = INT_MAX;
    for(int i=0;i<subS5List.size();++i){
        int dist = abs(order-subS5List[i].order);
        if(dist<best){
            while(orderMatch.size())
                orderMatch.pop();
            orderMatch.push(i);
            best = dist;
        } else if(dist==best){
            orderMatch.push(i);
        }
    }
    if(orderMatch.size()==1){
        std::cout<<subS5List[orderMatch.front()].name<<"\n";
    } else if(orderMatch.size()>1){
        auto mapDist = [](
            map<DegreeList,int> l,
            map<DegreeList,int>const& r)->int{

            for(auto &e: r){
                if(l.count(e.first))
                    l[e.first]-=e.second;
                else l[e.first] = e.second;
            }
            int out = 0;
            for(auto &e: l) out+=abs(e.second);
            return out;
        };
        int best = INT_MAX;
        int bestIdx=-1;
        for(;orderMatch.size();orderMatch.pop()){
            int idx = orderMatch.front();
            int dist = mapDist(table,subS5List[idx].cycle);
            if(dist<best) best = dist, bestIdx = idx;
        }
        std::cout<<subS5List[bestIdx].name<<"\n";
    } else puts("Unknown");

    //testMod();
    //testFraction();


    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
callq 0x247c
xorl %eax, %eax
leaq -0x130(%rbp), %rbx
movq %rax, (%rbx)
movq %rbx, 0x8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
movq %rax, 0x20(%rbx)
leaq -0xd8(%rbp), %rsi
movq %rsi, 0x8(%rsi)
movups %xmm0, 0x10(%rsi)
movq %rax, 0x20(%rsi)
leaq 0x10009a06(%rip), %rax  # 0x1000d1b4
movq %rax, (%rbx)
leaq 0x100099fd(%rip), %rax  # 0x1000d1b5
movq %rax, (%rsi)
movq 0x980e(%rip), %rdi      # 0xcfd0
callq 0x4c56
movq -0xc0(%rbp), %rdi
movq %rdi, %rax
subq -0xc8(%rbp), %rax
cmpq $0x11, %rax
jb 0x3814
addq $-0x10, %rdi
movl $0x1, %edx
xorl %esi, %esi
callq 0x5a8e
testb %al, %al
je 0x3814
movq -0xc0(%rbp), %rdi
addq $-0x10, %rdi
movq %rdi, -0xc0(%rbp)
movq %rdi, %rax
subq -0xc8(%rbp), %rax
cmpq $0x10, %rax
ja 0x37de
leaq -0x90(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
callq 0x28be
leaq -0x120(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movq -0x10(%rsi), %rax
movq %rax, -0x10(%rdi)
movq %rbx, -0x8(%rdi)
callq 0x7cc2
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x3851
callq 0x2180
movq 0x9760(%rip), %rdi      # 0xcfb8
leaq -0x130(%rbp), %rsi
callq 0x5051
leaq 0x57eb(%rip), %rsi      # 0x9056
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
leaq -0x160(%rbp), %rdi
leaq -0x130(%rbp), %rsi
movl $0x4e20, %edx           # imm = 0x4E20
callq 0x2a39
leaq -0x158(%rbp), %r12
movq 0x10(%r12), %rbx
cmpq %r12, %rbx
je 0x3927
leaq -0x90(%rbp), %r14
leaq 0x57a3(%rip), %r13      # 0x9056
leaq 0x20(%rbx), %rsi
movq %r14, %rdi
callq 0x5de8
movl 0x38(%rbx), %eax
movl %eax, -0x78(%rbp)
movq 0x96ec(%rip), %rdi      # 0xcfb8
movq %r14, %rsi
callq 0x5165
movq %rax, %r15
movl $0x2, %edx
movq %rax, %rdi
leaq 0x579b(%rip), %rsi      # 0x9081
callq 0x21c0
movl -0x78(%rbp), %esi
movq %r15, %rdi
callq 0x2290
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x21c0
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x3917
callq 0x2180
movq %rbx, %rdi
callq 0x2110
movq %rax, %rbx
cmpq %r12, %rax
jne 0x38b3
movq -0x148(%rbp), %rax
xorl %ebx, %ebx
cmpq %r12, %rax
je 0x3942
addl 0x38(%rax), %ebx
movq %rax, %rdi
callq 0x2110
jmp 0x3930
movq 0x966f(%rip), %rdi      # 0xcfb8
leaq 0x572c(%rip), %rsi      # 0x907c
movl $0x7, %edx
callq 0x21c0
movq 0x9657(%rip), %rdi      # 0xcfb8
movl %ebx, %esi
callq 0x2290
leaq 0x56e7(%rip), %rsi      # 0x9056
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
leaq -0xb0(%rbp), %rdi
callq 0x344f
xorps %xmm0, %xmm0
leaq -0x90(%rbp), %rdi
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %esi, %esi
callq 0x7d9a
movl $0x0, -0x2c(%rbp)
movq -0xb0(%rbp), %rax
cmpq %rax, -0xa8(%rbp)
je 0x3b0b
xorl %ecx, %ecx
movl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
leaq -0x2c(%rbp), %r15
movabsq $0x2e8ba2e8ba2e8ba3, %r12 # imm = 0x2E8BA2E8BA2E8BA3
imulq $0x58, %rcx, %rdx
movl %ebx, %esi
subl 0x20(%rax,%rdx), %esi
movl %esi, %r14d
negl %r14d
cmovsl %esi, %r14d
cmpl %r13d, %r14d
jge 0x3a7e
movq -0x48(%rbp), %rax
movq %rax, %rcx
subq -0x68(%rbp), %rcx
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
shlq $0x7, %rcx
movq -0x60(%rbp), %rax
movq %rax, %rsi
subq -0x58(%rbp), %rsi
sarq $0x2, %rsi
addq %rcx, %rsi
movq -0x80(%rbp), %rcx
movq -0x70(%rbp), %rdx
movq %rdx, %rdi
subq %rcx, %rdi
sarq $0x2, %rdi
addq %rsi, %rdi
je 0x3a98
addq $-0x4, %rdx
cmpq %rdx, %rcx
je 0x3a4d
addq $0x4, %rcx
jmp 0x3a75
movq -0x78(%rbp), %rdi
callq 0x2180
movq -0x68(%rbp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, -0x68(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x78(%rbp)
leaq 0x200(%rcx), %rax
movq %rax, -0x70(%rbp)
movq %rcx, -0x80(%rbp)
jmp 0x39fa
jne 0x3ab4
movq -0x60(%rbp), %rax
movq -0x50(%rbp), %rdx
addq $-0x4, %rdx
cmpq %rdx, %rax
je 0x3aca
movl %ecx, (%rax)
movl %r13d, %r14d
jmp 0x3aaa
movq -0x50(%rbp), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x3ab9
movl -0x2c(%rbp), %ecx
movl %ecx, (%rax)
addq $0x4, %rax
movq %rax, -0x60(%rbp)
jmp 0x3adc
movl %r13d, %r14d
jmp 0x3adc
leaq -0x90(%rbp), %rdi
movq %r15, %rsi
callq 0x7f14
jmp 0x3adc
leaq -0x90(%rbp), %rdi
movq %r15, %rsi
callq 0x7f14
movl %r13d, %r14d
movslq -0x2c(%rbp), %rcx
incq %rcx
movl %ecx, -0x2c(%rbp)
movq -0xb0(%rbp), %rax
movq -0xa8(%rbp), %rdx
subq %rax, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
movl %r14d, %r13d
cmpq %rcx, %rdx
ja 0x39dd
movq -0x48(%rbp), %rcx
movq %rcx, %rdx
subq -0x68(%rbp), %rdx
shrq $0x3, %rdx
cmpq $0x1, %rcx
adcq $-0x1, %rdx
movq -0x60(%rbp), %rsi
subq -0x58(%rbp), %rsi
shlq $0x7, %rdx
sarq $0x2, %rsi
addq %rdx, %rsi
movq -0x80(%rbp), %rcx
movq -0x70(%rbp), %rdx
subq %rcx, %rdx
sarq $0x2, %rdx
addq %rsi, %rdx
je 0x3b84
cmpq $0x1, %rdx
jne 0x3b95
movslq (%rcx), %rcx
imulq $0x58, %rcx, %rcx
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq 0x9452(%rip), %rdi      # 0xcfb8
callq 0x21c0
leaq 0x54e4(%rip), %rsi      # 0x9056
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
jmp 0x3d5e
leaq 0x54f9(%rip), %rdi      # 0x9084
callq 0x2240
jmp 0x3d5e
leaq -0x100(%rbp), %r12
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movq -0x48(%rbp), %rax
movq %rax, %rcx
subq -0x68(%rbp), %rcx
shrq $0x3, %rcx
cmpq $0x1, %rax
adcq $-0x1, %rcx
movq -0x60(%rbp), %rdx
subq -0x58(%rbp), %rdx
shlq $0x7, %rcx
sarq $0x2, %rdx
addq %rcx, %rdx
movq -0x80(%rbp), %rax
movq -0x70(%rbp), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
addq %rdx, %rcx
je 0x3d27
movl %ebx, -0x30(%rbp)
movq %r12, %rbx
movl %r14d, -0x34(%rbp)
movslq (%rax), %r14
leaq -0x108(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x52aa
movq -0xb0(%rbp), %rax
movq %r14, -0x98(%rbp)
imulq $0x58, %r14, %rcx
leaq (%rax,%rcx), %r13
addq $0x30, %r13
movq 0x10(%r13), %r15
cmpq %r13, %r15
je 0x3c7e
leaq 0x20(%r15), %r12
leaq -0x108(%rbp), %rdi
movq %r12, %rsi
callq 0x6aa6
movl 0x38(%r15), %r14d
cmpq %rbx, %rax
je 0x3c5c
leaq -0x108(%rbp), %rdi
movq %r12, %rsi
callq 0x4a06
subl %r14d, (%rax)
jmp 0x3c6e
leaq -0x108(%rbp), %rdi
movq %r12, %rsi
callq 0x4a06
movl %r14d, (%rax)
movq %r15, %rdi
callq 0x21d0
movq %rax, %r15
cmpq %r13, %rax
jne 0x3c2c
movq -0xf0(%rbp), %rax
movq %rbx, %r12
xorl %r15d, %r15d
cmpq %rbx, %rax
je 0x3cba
movl -0x34(%rbp), %r14d
movl -0x30(%rbp), %ebx
movq -0x98(%rbp), %r13
movl 0x38(%rax), %ecx
movl %ecx, %edx
negl %edx
cmovsl %ecx, %edx
addl %edx, %r15d
movq %rax, %rdi
callq 0x2110
cmpq %r12, %rax
jne 0x3c9e
jmp 0x3cc8
movl -0x34(%rbp), %r14d
movl -0x30(%rbp), %ebx
movq -0x98(%rbp), %r13
leaq -0x108(%rbp), %rdi
callq 0x521e
cmpl %ebx, %r15d
cmovll %r15d, %ebx
cmovll %r13d, %r14d
movq -0x80(%rbp), %rax
movq -0x70(%rbp), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rax
je 0x3cf6
addq $0x4, %rax
jmp 0x3d1e
movq -0x78(%rbp), %rdi
callq 0x2180
movq -0x68(%rbp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, -0x68(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
leaq 0x200(%rax), %rcx
movq %rcx, -0x70(%rbp)
movq %rax, -0x80(%rbp)
jmp 0x3ba7
movslq %r14d, %rax
movq -0xb0(%rbp), %rcx
imulq $0x58, %rax, %rax
movq (%rcx,%rax), %rsi
movq 0x8(%rcx,%rax), %rdx
movq 0x9273(%rip), %rdi      # 0xcfb8
callq 0x21c0
leaq 0x5305(%rip), %rsi      # 0x9056
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
leaq -0x90(%rbp), %rdi
callq 0x54be
leaq -0xb0(%rbp), %rdi
callq 0x501e
leaq -0x160(%rbp), %rdi
callq 0x521e
movq -0xc8(%rbp), %rdi
testq %rdi, %rdi
je 0x3d93
callq 0x2180
movq -0x120(%rbp), %rdi
testq %rdi, %rdi
je 0x3da4
callq 0x2180
xorl %eax, %eax
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3de5
jmp 0x3de5
movq %rax, %rbx
jmp 0x3e20
jmp 0x3dea
jmp 0x3de0
movq %rax, %rbx
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x3e38
callq 0x2180
jmp 0x3e38
jmp 0x3de0
jmp 0x3dea
jmp 0x3de0
jmp 0x3de5
movq %rax, %rbx
jmp 0x3e38
movq %rax, %rbx
jmp 0x3e14
movq %rax, %rbx
jmp 0x3e2c
movq %rax, %rbx
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x3e2c
callq 0x2180
jmp 0x3e2c
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
callq 0x521e
leaq -0x90(%rbp), %rdi
callq 0x54be
leaq -0xb0(%rbp), %rdi
callq 0x501e
leaq -0x160(%rbp), %rdi
callq 0x521e
movq -0xc8(%rbp), %rdi
testq %rdi, %rdi
je 0x3e49
callq 0x2180
movq -0x120(%rbp), %rdi
testq %rdi, %rdi
je 0x3e5a
callq 0x2180
movq %rbx, %rdi
callq 0x22a0