// File: /workspace/github_cpp_makefile_star2_O3/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 $0x148, %rsp            # imm = 0x148
callq 0x247c
leaq -0x138(%rbp), %rbx
movq %rbx, 0x8(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
xorl %eax, %eax
movq %rax, 0x20(%rbx)
leaq -0xe0(%rbp), %rsi
movq %rsi, 0x8(%rsi)
movups %xmm0, 0x10(%rsi)
movq %rax, 0x20(%rsi)
leaq 0x10009a1b(%rip), %rax  # 0x1000d1b4
movq %rax, (%rbx)
leaq 0x10009a12(%rip), %rax  # 0x1000d1b5
movq %rax, (%rsi)
movq 0x9823(%rip), %rdi      # 0xcfd0
callq 0x4c2b
movq -0xc8(%rbp), %rdi
movq %rdi, %rax
subq -0xd0(%rbp), %rax
cmpq $0x11, %rax
jb 0x37ff
addq $-0x10, %rdi
movl $0x1, %edx
xorl %esi, %esi
callq 0x5a5e
testb %al, %al
je 0x37ff
movq -0xc8(%rbp), %rdi
addq $-0x10, %rdi
movq %rdi, -0xc8(%rbp)
movq %rdi, %rax
subq -0xd0(%rbp), %rax
cmpq $0x10, %rax
ja 0x37c9
leaq -0x90(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x28bc
leaq -0x128(%rbp), %rdi
leaq -0x80(%rbp), %rsi
movq -0x10(%rsi), %rax
movq %rax, -0x10(%rdi)
movq %rbx, -0x8(%rdi)
callq 0x7c20
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x383c
callq 0x2180
movq 0x9775(%rip), %rdi      # 0xcfb8
leaq -0x138(%rbp), %rsi
callq 0x5029
leaq 0x5800(%rip), %rsi      # 0x9056
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
leaq -0x168(%rbp), %rdi
leaq -0x138(%rbp), %rsi
movl $0x4e20, %edx           # imm = 0x4E20
callq 0x2a34
leaq -0x160(%rbp), %r12
movq 0x10(%r12), %r14
cmpq %r12, %r14
je 0x391a
leaq -0x90(%rbp), %rbx
leaq 0x57b8(%rip), %r13      # 0x9056
leaq 0x20(%r14), %rsi
movq %rbx, %rdi
callq 0x5dac
movl 0x38(%r14), %eax
movl %eax, -0x78(%rbp)
movq 0x9700(%rip), %rdi      # 0xcfb8
movq %rbx, %rsi
callq 0x512c
movq %rax, %r15
movl $0x2, %edx
movq %rax, %rdi
leaq 0x57af(%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 0x3903
callq 0x2180
movq %r14, %rdi
callq 0x2110
movq %rax, %r14
cmpq %r12, %rax
jne 0x389e
movq -0x150(%rbp), %r14
xorl %ebx, %ebx
cmpq %r12, %r14
je 0x3935
addl 0x38(%r14), %ebx
movq %r14, %rdi
callq 0x2110
movq %rax, %r14
cmpq %r12, %rax
jne 0x3921
movq 0x967c(%rip), %rdi      # 0xcfb8
leaq 0x5739(%rip), %rsi      # 0x907c
movl $0x7, %edx
callq 0x21c0
movq 0x9664(%rip), %rdi      # 0xcfb8
movl %ebx, %esi
callq 0x2290
leaq 0x56f4(%rip), %rsi      # 0x9056
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
leaq -0xa8(%rbp), %rdi
callq 0x343d
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 0x7d06
movl $0x0, -0x2c(%rbp)
movq -0xa8(%rbp), %rcx
cmpq %rcx, -0xa0(%rbp)
je 0x3afe
xorl %eax, %eax
movl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
leaq -0x2c(%rbp), %r15
movabsq $0x2e8ba2e8ba2e8ba3, %r12 # imm = 0x2E8BA2E8BA2E8BA3
imulq $0x58, %rax, %rdx
movl %ebx, %esi
subl 0x20(%rcx,%rdx), %esi
movl %esi, %r14d
negl %r14d
cmovsl %esi, %r14d
cmpl %r13d, %r14d
jge 0x3a71
movq -0x68(%rbp), %rax
movq -0x80(%rbp), %rcx
movq -0x70(%rbp), %rdx
movq -0x60(%rbp), %rsi
movq -0x48(%rbp), %rdi
movq %rdi, %r8
subq %rax, %r8
shrq $0x3, %r8
cmpq $0x1, %rdi
adcq $-0x1, %r8
shlq $0x7, %r8
movq %rsi, %rdi
subq -0x58(%rbp), %rdi
sarq $0x2, %rdi
addq %r8, %rdi
movq %rdx, %r8
subq %rcx, %r8
sarq $0x2, %r8
addq %rdi, %r8
je 0x3a8b
leaq -0x4(%rdx), %rsi
cmpq %rsi, %rcx
je 0x3a43
addq $0x4, %rcx
jmp 0x3a6b
movq -0x78(%rbp), %rdi
callq 0x2180
movq -0x68(%rbp), %rcx
leaq 0x8(%rcx), %rax
movq %rax, -0x68(%rbp)
movq 0x8(%rcx), %rcx
movq %rcx, -0x78(%rbp)
leaq 0x200(%rcx), %rdx
movq %rdx, -0x70(%rbp)
movq %rcx, -0x80(%rbp)
jmp 0x39f9
jne 0x3aa7
movq -0x60(%rbp), %rsi
movq -0x50(%rbp), %rcx
addq $-0x4, %rcx
cmpq %rcx, %rsi
je 0x3abd
movl %eax, (%rsi)
movl %r13d, %r14d
jmp 0x3a9d
movq -0x50(%rbp), %rax
addq $-0x4, %rax
cmpq %rax, %rsi
je 0x3aac
movl -0x2c(%rbp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, -0x60(%rbp)
jmp 0x3acf
movl %r13d, %r14d
jmp 0x3acf
leaq -0x90(%rbp), %rdi
movq %r15, %rsi
callq 0x7e80
jmp 0x3acf
leaq -0x90(%rbp), %rdi
movq %r15, %rsi
callq 0x7e80
movl %r13d, %r14d
movslq -0x2c(%rbp), %rax
incq %rax
movl %eax, -0x2c(%rbp)
movq -0xa8(%rbp), %rcx
movq -0xa0(%rbp), %rdx
subq %rcx, %rdx
sarq $0x3, %rdx
imulq %r12, %rdx
movl %r14d, %r13d
cmpq %rax, %rdx
ja 0x39d0
movq -0x48(%rbp), %rsi
movq %rsi, %rdx
subq -0x68(%rbp), %rdx
shrq $0x3, %rdx
cmpq $0x1, %rsi
movq %rdx, %r8
adcq $-0x1, %r8
movq -0x60(%rbp), %rdi
subq -0x58(%rbp), %rdi
shlq $0x7, %r8
sarq $0x2, %rdi
addq %rdi, %r8
movq -0x80(%rbp), %rax
movq -0x70(%rbp), %r9
subq %rax, %r9
sarq $0x2, %r9
addq %r9, %r8
je 0x3b7a
cmpq $0x1, %r8
jne 0x3b8b
movslq (%rax), %rax
imulq $0x58, %rax, %rax
movq (%rcx,%rax), %rsi
movq 0x8(%rcx,%rax), %rdx
movq 0x945c(%rip), %rdi      # 0xcfb8
callq 0x21c0
leaq 0x54ee(%rip), %rsi      # 0x9056
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
jmp 0x3d6b
leaq 0x5503(%rip), %rdi      # 0x9084
callq 0x2240
jmp 0x3d6b
cmpq $0x1, %rsi
adcq $-0x1, %rdx
shlq $0x7, %rdx
addq %rdi, %rdx
movq $-0x1, %rcx
addq %r9, %rdx
je 0x3d37
leaq -0x108(%rbp), %r12
movl $0x7fffffff, %r15d      # imm = 0x7FFFFFFF
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
leaq -0x110(%rbp), %r13
movl %r15d, -0x30(%rbp)
movl %ebx, -0x34(%rbp)
movslq (%rax), %rbx
movq %r13, %rdi
leaq -0x168(%rbp), %rsi
callq 0x5274
movq -0xa8(%rbp), %rax
movq %rbx, -0xb0(%rbp)
imulq $0x58, %rbx, %rcx
addq %rcx, %rax
addq $0x30, %rax
movq 0x10(%rax), %r15
movq %rax, -0xb8(%rbp)
cmpq %rax, %r15
je 0x3c57
leaq 0x20(%r15), %r13
leaq -0x110(%rbp), %r14
movq %r14, %rdi
movq %r13, %rsi
callq 0x6a4e
movq %rax, %r12
movl 0x38(%r15), %ebx
movq %r14, %rdi
movq %r13, %rsi
callq 0x49d4
movl (%rax), %ecx
subl %ebx, %ecx
leaq -0x108(%rbp), %r14
cmpq %r14, %r12
movq %r14, %r12
cmovel %ebx, %ecx
movl %ecx, (%rax)
movq %r15, %rdi
callq 0x21d0
movq %rax, %r15
cmpq -0xb8(%rbp), %rax
jne 0x3c05
movq -0xf8(%rbp), %rax
xorl %r14d, %r14d
cmpq %r12, %rax
je 0x3c90
movl -0x34(%rbp), %ebx
movl -0x30(%rbp), %r15d
leaq -0x110(%rbp), %r13
movl 0x38(%rax), %ecx
movl %ecx, %edx
negl %edx
cmovsl %ecx, %edx
addl %edx, %r14d
movq %rax, %rdi
callq 0x2110
cmpq %r12, %rax
jne 0x3c74
jmp 0x3c9e
movl -0x34(%rbp), %ebx
movl -0x30(%rbp), %r15d
leaq -0x110(%rbp), %r13
movq %r13, %rdi
callq 0x51e8
cmpl %r15d, %r14d
cmovll %r14d, %r15d
cmovll -0xb0(%rbp), %ebx
movq -0x80(%rbp), %rax
movq -0x70(%rbp), %rcx
leaq -0x4(%rcx), %rdx
cmpq %rdx, %rax
je 0x3ccf
addq $0x4, %rax
movq -0x68(%rbp), %rdx
jmp 0x3cf7
movq -0x78(%rbp), %rdi
callq 0x2180
movq -0x68(%rbp), %rax
leaq 0x8(%rax), %rdx
movq %rdx, -0x68(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x78(%rbp)
leaq 0x200(%rax), %rcx
movq %rcx, -0x70(%rbp)
movq %rax, -0x80(%rbp)
movq -0x60(%rbp), %rsi
movq -0x48(%rbp), %rdi
movq %rdi, %r8
subq %rdx, %r8
shrq $0x3, %r8
cmpq $0x1, %rdi
adcq $-0x1, %r8
shlq $0x7, %r8
subq -0x58(%rbp), %rsi
sarq $0x2, %rsi
addq %r8, %rsi
subq %rax, %rcx
sarq $0x2, %rcx
addq %rsi, %rcx
jne 0x3bc3
movslq %ebx, %rcx
movq -0xa8(%rbp), %rax
imulq $0x58, %rcx, %rcx
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
movq 0x9266(%rip), %rdi      # 0xcfb8
callq 0x21c0
leaq 0x52f8(%rip), %rsi      # 0x9056
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
leaq -0x90(%rbp), %rdi
callq 0x5488
leaq -0xa8(%rbp), %rdi
callq 0x4ff6
leaq -0x168(%rbp), %rdi
callq 0x51e8
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0x3da0
callq 0x2180
movq -0x128(%rbp), %rdi
testq %rdi, %rdi
je 0x3db1
callq 0x2180
xorl %eax, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3ded
jmp 0x3ded
movq %rax, %rbx
jmp 0x3e2d
jmp 0x3df7
jmp 0x3df2
movq %rax, %rbx
movq -0x80(%rbp), %rdi
testq %rdi, %rdi
je 0x3e45
callq 0x2180
jmp 0x3e45
jmp 0x3df2
jmp 0x3df7
jmp 0x3df2
jmp 0x3ded
movq %rax, %rbx
jmp 0x3e21
movq %rax, %rbx
jmp 0x3e45
movq %rax, %rbx
jmp 0x3e39
movq %rax, %rbx
movq -0x90(%rbp), %rdi
testq %rdi, %rdi
je 0x3e39
callq 0x2180
jmp 0x3e39
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
callq 0x51e8
leaq -0x90(%rbp), %rdi
callq 0x5488
leaq -0xa8(%rbp), %rdi
callq 0x4ff6
leaq -0x168(%rbp), %rdi
callq 0x51e8
movq -0xd0(%rbp), %rdi
testq %rdi, %rdi
je 0x3e56
callq 0x2180
movq -0x128(%rbp), %rdi
testq %rdi, %rdi
je 0x3e67
callq 0x2180
movq %rbx, %rdi
callq 0x22a0