NZEC Error

This is my code when I execute It on the ide it works well but while submitting it shows NZEC Runtime error. Please help.

import java.util.Scanner;

 class codechef {
static char[] coin;
static int n,i,q;
static void flipcoins(int side)
{
  if(side==1)
      for(int i1=0;i1<n;i1++)
          coin[i1]='H';
  else
      for(int i1=0;i1<n;i1++)
          coin[i1]='T';
}
static void changeside()
{
    for(int a=0;a<n;a++)
    {
     for(int j=0;j<=a;j++)
     {
         if(coin[j]=='H')
             coin[j]='T';
         else
             coin[j]='H';
     }
    }
}
 static void count()
 {
    int nt=0,nh=0;
    for(int i1=0;i1<n;i1++)
    {
       if(coin[i1]=='H')
           nh++;
       else
           nt++;
    }
    if(q==1)
        System.out.println(nh);
    else
        System.out.println(nt);
}
public static void main(String[] args) {
   int t;
   try{
   Scanner sc= new Scanner(System.in);
   t=sc.nextInt();
   while(t-->0)
   {
    int g=sc.nextInt();
    while(g-->0)
    {
      i=sc.nextInt();
      n=sc.nextInt();
      q=sc.nextInt();
      coin= new char[n];
      flipcoins(i);
      changeside();
      count();
    }
    
   }
}catch(Exception e)
{ System.out.println(e);}
}
 }
//