Under construction

Still being built. Things may change

Math Teacher's Worry (Hard)

Time limit1sMemory limit1024 MB

Summary
Given a positive integer n, factor n x^2 + (n+1)x - (n+2) over the integers and print (a, b, c, d), or -1 if no factorization exists.
Level

Medium5 of 10

Topics
Math, Number theory, Implementation
Solved
No attempts yet

Problem

This problem is a harder version of Math Teacher's Worry (Easy). You can solve this problem and submit its correct code to Math Teacher's Worry (Easy) to get accepted.

Teacher Hyeongjun Cha was thinking about an interesting problem as usual. He came up with a problem that asks to factor the quadratic nx2+(n+1)x−(n+2)n x^2 + (n+1) x - (n+2) over the integers, for a positive integer nn.

For small nn, he could work it out by hand. As nn grew, the problem became hard.

So the teacher gave the problem to Dohun, who is not strong at math but writes code as instructed. However, Dohun has only copied and pasted code that ChatGPT gave him, and he can barely print "Hello World!". So he asked ChatGPT to write the code, as he usually does.

But the internet went down while he was waiting for the answer.

The image shows the moment the internet cut out while Dohun was asking ChatGPT to write a program.

Help Dohun write a program that factors nx2+(n+1)x−(n+2)n x^2 + (n+1) x - (n+2) over the integers.

Input

The first line contains a positive integer nn.

Output

If nx2+(n+1)x−(n+2)n x^2 + (n+1) x - (n+2) cannot be factored over the integers, print -1. Otherwise, print four integers aa, bb, cc, dd separated by spaces, which means (ax+b)(cx+d)=nx2+(n+1)x−(n+2)(ax+b)(cx+d)=n x^2 + (n+1) x - (n+2). If there are several valid (a,b,c,d)(a,b,c,d) tuples, print any one of them.

Constraints

1≤n≤2×1061\le n\le 2\times 10^6.

Examples2

  1. Example 1

    Input
    1
    
    Expected output
    1 -1 1 3
    
  2. Example 2

    Input
    2
    
    Expected output
    -1