template <class Int>
Int Pow(Int x,Int r){
  Int t=1;
  do{
    if(r%2) t*=x;
    x*=x;
  }while(r/=2);
  return t;
}