java to puthon converter
import java.util.*;
import java.lang.*;
import java.io.*;
// Please name your class Main
class Main {
public static void main(String[] args) {
int answer=0,mod=1;
double value;
Scanner in = new Scanner(System.in);
int p = in.nextInt();
int q = in.nextInt();
int n = in.nextInt();
int m = in.nextInt();
if(1<=p && p<=1000){
if(0<=q && q<=1000){
if(1<=n || m<=(10^9)){
for(int i=1;i<=n;i++) {
value = Math.pow(p, i) * Math.pow(i, q) ;
answer+=value;
mod= answer % m;
}
System.out.println(mod);
}
}
}
}
}