Stax, 14 13 bytes
ü±p╞Ö*«òτ♀╣â▀
Explanation (unpacked):
m|fc%c{vsH1?}U? Full program, implicit input-parsing
m Map
|fc%c Get factorisation and length of it (0 and 1 yield [])
{ } ? If length != 0:
v Decrement
? If still != 0:
sH Last element of factorisation
? Else:
1 Push 1
? Else:
U Push -1
Pseudocode inside map:
f = factorisation(i)
l = length(f)
if l:
if --l:
return f[-1]
else:
return 1
else:
return -1