#P2056. ACSL 2019-2020 Senior Division Contest #1 Number Transformation

ACSL 2019-2020 Senior Division Contest #1 Number Transformation

Given a positive integer (call it NN) and a position in that integer (call it PP) transform NN. To transform NN, find the PthP^{th} digit of NN from the right:

  • Replace each of the digits to the left by the sum of that digit and the PthP^{th} digit.
  • Replace each of the digits to the right by the absolute value of the difference between it and the PthP^{th} digit.
  • Replace the PthP^{th} digit by the number of different prime factors of NN. Note that 11 is not a prime number, and it has no prime factors. A prime number has exactly one prime factor (namely, itself).

INPUT FORMAT

There will be 55 sets of data. Each set contains two positive integers: NN and PP. NN will be less than 10151015, and PP will be valid.

OUTPUT FORMAT

The transformed value of each input set. The printed number may not have any spaces between the digits.

SAMPLE

INPUT

102438 3
4329 1
6710 2
16807 1
60098065452 7

OUTPUT

546414
1312113
7841
8131571
1488173823436