#include using namespace std; #include "atcoder/modint" using namespace atcoder; using mint=modint; int main(void) { int n,b; long long m; cin >> n >> m >> b; mint::set_mod(b); mint ans=1; vector a(n); for(int i=0;i> a[i]; ans*=1+mint(m).pow(a[i]); } cout << ans.val() << endl; return 0; }