---
# System prepended metadata

title: $N$ in power of $N$

---

# $N$ in power of $N$

Given two integers $N$ and $M$. Calculate $N^N\pmod M$.

## Input format
The input contains two integers $N$ and $M$ ($1 \le 10^9$, $2 \le M \le 10^9$).

## Output format
Print one integer - the value of $N^N\pmod M$.

## Sample 1
### Input
```
3 1001
```

### Output
```
27
```

## Sample 2
### Input
```
10 123456
```

### Output
```
64000
```