private static int findPrimitiveRoot(int num) {
		TreeSet<Integer>list=new TreeSet<Integer>();
		for(int j=1;j<num;++j){
			list.clear();
			for(int i=0;i<num;++i){
				list.add(pwr(j,i,num));
				if(list.size()!=i+1) break;
			}
			if(list.size()==num-1){
				return j;
			}
		}
		return 0;
	}