Getting runtime error NZEC: in magicchef problem using java

program is totally working in my system but i am getting NZEC error while sumitting it codechef
import java.util.Scanner;
public class Main
{
public static void magic(int a[])

{
	Scanner in = new Scanner(System.in);
	int x;
	x = in.nextInt();
	x=x-1;
	a[x]=1;
	int s;
	s=in.nextInt();
	for(int i=0;i<s;i++)
	{
		int a1,b1;
		a1=in.nextInt();
		b1=in.nextInt();
		a1=a1-1;
		b1=b1-1;
		int temp;
		temp=a[a1];
		a[a1]=a[b1];
		a[b1]=temp;
	}
	for(int i=0;i<a.length;i++)
	{
		if(a[i]==1)
		{	
			System.out.println(i+1);

		}
	}
}
	public static void main(String args[])
	{
		int n;
		Scanner in=new Scanner(System.in);
		int t;
		do
		{	
			System.out.println("Enter t:");
			t=in.nextInt();
		}while(!(t>=1 && t<=100));
		for(int j=0;j<t;j++)
		{
			n=in.nextInt();
			int a[]=new int[n];	
			for(int i=0;i<n;i++)
			{
					a[i]=0;
				}
			magic(a);
		}
}

}

//