Basically Speaking
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scan =new Scanner(System.in);
String regex="[\\s+]";
int timer=0;
while(scan.hasNextLine()) {
String str=scan.nextLine();
String S[]=str.split(regex);
int num=Integer.valueOf(S[0],Integer.parseInt(S[1]));
String ans=Integer.toString(num, Integer.parseInt(S[2]));
if(ans.length()>=7)
System.out.println(" ERROR");
else
System.out.printf("%7s\n",ans);
timer++;
if(timer==10)
break;
}
}
}