PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#SP0000069. Vị trí nguyên tố trong tam giác (Primes Triangle (I))

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Vị trí nguyên tố trong tam giác (Primes Triangle (I))

Primes Triangle (I)

Source: SPOJ

Version: Phuoc Hung OJ Extended

Problem Statement

Arrange increasing primes into a triangle: row 11 has 22; row 22 has 3,53,5; row 33 has 7,11,137,11,13; row 44 has 17,19,23,2917,19,23,29; and row rr has rr primes. Rows and columns are indexed from 11. Given positive integer nn, print its row and column in this triangle if nn is prime; otherwise report that it does not appear.

Input

One line contains integer nn.

Output

If nn is prime, print two integers i,ji,j: its one-based row and column. Otherwise print -1.

Subtasks

  • Subtask 1 (20 points): 1≤n≤100001\le n\le 10000.
  • Subtask 2 (30 points): 1≤n≤10000001\le n\le 1000000.
  • Subtask 3 (50 points): 1≤n≤1000000001\le n\le 100000000.

Examples

Input

23

Output

4 3

Explanation

The primes start 2,3,5,7,11,13,17,19,23,292,3,5,7,11,13,17,19,23,29. The prime 2323 has rank 99. The first three rows contain 1+2+3=61+2+3=6 entries, so 2323 lies in row 44. That row is 17,19,23,2917,19,23,29, making its column 33: print 4 3.