Replace all pi getting run time error on coding blocks but code running fine on eclipse

import java.io.;
import java.util.
;

public class Main {

public static String replace(String str,int idx)
{
	if(str.contentEquals("pi")) return "3.14";
	if(idx==str.length() -2)
		return str;
	String cs="";
	cs=str.substring(idx,idx+2);
	String res = replace(str,idx+1);
	if(cs.equalsIgnoreCase("pi"))
		res = res.substring(0,idx)+"3.14"+res.substring(idx+2);
	return res;
}
public static void main(String[] args)throws IOException
{
	// TODO Auto-generated method stub
	//Scanner sc = new Scanner(System.in);
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int t = Integer.parseInt(br.readLine());
	String a[]=new String[t];
	
	for(int i=0;i<t;i++)
	 {a[i] = br.readLine();
	  a[i]=replace(a[i],0);}
	for(int i=0;i<t;i++)
	System.out.println(a[i]);}

}

Your code should throw Runtime Error for inputs of length 1.

thanks . got my mistake.