, {2, 1, 3}, {2, 3, 1}, {3, 1, 2}, {3, 2, 1} are legal, so the answer is 6 mod 5 = 1
/**
hdu 5187 高速幂高速乘法...algorithm>#include using namespace std;typedef long long LL;LL n,p;LL qui_mul(LL x,LL m)///高速乘法...re=(re+x)%p; } x=(x+x)%p; m>>=1; } return re;}LL qui_pow(LL a,LL n)///高速幂