#include "bits/stdc++.h"
using namespace std;
#define int long long
#define F first
#define S second
#define sz(x) ((int)x.size())
#define rep(i,a,n) for (int i = a; i <= n; ++i)
#define all(v) v.begin(), v.end()
#define pb push_back
#define P pair < int, int >
#define E cout << '\n'
const int mod = 1e9 + 7;
const int N = 3e5 + 5;
int gcd(int a, int b, int *x, int *y) {
if (a == 0) {
*x = 0;
*y = 1;
return b;
}
int x1, y1;
int gcd1 = gcd(b%a, a, &x1, &y1);
*x = y1 - (b/a) * x1;
*y = x1;
return gcd1;
}
int po(int x, int n, int mod) {
int res = 1;
while(n) {
if (n & 1) {
res = (res * x) % mod;
}
n /= 2;
x = (x * x) % mod;
}
return res;
}
int get(int n, int mod) {
int ans = 0;
rep(i, 1, n)
ans = (ans + po(i, i, mod)) % mod;
return ans;
}
signed main() {
int x, y, n, Mod = pow(5, 10);
cin >> n;
int a = get(n, 1024);
gcd(Mod, 1024, &x, &y);
int ans1 = x * Mod * a;
int b = get(n, Mod);
// cout << a << ' ' << b << '\n';
int ans2 = y * 1024 * b;
cout << ((ans1 + ans2 ) % (int)1e10 + (int)1e10) % (int)1e10;
return 0;
}
I2luY2x1ZGUgImJpdHMvc3RkYysrLmgiCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIGludCBsb25nIGxvbmcKI2RlZmluZSBGIGZpcnN0CiNkZWZpbmUgUyBzZWNvbmQKI2RlZmluZSBzeih4KSAoKGludCl4LnNpemUoKSkKI2RlZmluZSByZXAoaSxhLG4pIGZvciAoaW50IGkgPSBhOyBpIDw9IG47ICsraSkKI2RlZmluZSBhbGwodikgIHYuYmVnaW4oKSwgdi5lbmQoKQojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIFAgcGFpciA8IGludCwgaW50ID4KI2RlZmluZSBFIGNvdXQgPDwgJ1xuJwoKY29uc3QgaW50IG1vZCA9IDFlOSArIDc7CmNvbnN0IGludCBOID0gM2U1ICsgNTsKCmludCBnY2QoaW50IGEsIGludCBiLCBpbnQgKngsIGludCAqeSkgeyAKICAgIGlmIChhID09IDApICAgICB7IAogICAgICAgICp4ID0gMDsgCiAgICAgICAgKnkgPSAxOyAKICAgICAgICByZXR1cm4gYjsgCiAgICB9IAogICAgaW50IHgxLCB5MTsKICAgIGludCBnY2QxID0gZ2NkKGIlYSwgYSwgJngxLCAmeTEpOyAKICAgICp4ID0geTEgLSAoYi9hKSAqIHgxOyAKICAgICp5ID0geDE7ICAgCiAgICByZXR1cm4gZ2NkMTsgCn0gCmludCBwbyhpbnQgeCwgaW50IG4sIGludCBtb2QpIHsKCWludCByZXMgPSAxOwoJd2hpbGUobikgewoJCWlmIChuICYgMSkgewoJCQlyZXMgPSAocmVzICogeCkgJSBtb2Q7CgkJfQoJCW4gLz0gMjsKCQl4ID0gKHggKiB4KSAlIG1vZDsKCX0KCXJldHVybiByZXM7Cn0KaW50IGdldChpbnQgbiwgaW50IG1vZCkgewoJaW50IGFucyA9IDA7CglyZXAoaSwgMSwgbikgCgkJYW5zID0gKGFucyArIHBvKGksIGksIG1vZCkpICUgbW9kOwoJcmV0dXJuIGFuczsKfQpzaWduZWQgbWFpbigpIHsKCWludCB4LCB5LCBuLCBNb2QgPSBwb3coNSwgMTApOwoJY2luID4+IG47CgoJaW50IGEgPSBnZXQobiwgMTAyNCk7CgoKCWdjZChNb2QsIDEwMjQsICZ4LCAmeSk7CgoJaW50IGFuczEgPSB4ICogTW9kICogYTsKCglpbnQgYiA9IGdldChuLCBNb2QpOwoJLy8gY291dCA8PCBhIDw8ICcgJyA8PCBiIDw8ICdcbic7CglpbnQgYW5zMiA9IHkgKiAxMDI0ICogYjsKCgljb3V0IDw8ICgoYW5zMSArIGFuczIgKSAlIChpbnQpMWUxMCArIChpbnQpMWUxMCkgJSAoaW50KTFlMTA7CgoKCgoKCgoKCgogICAgcmV0dXJuIDA7Cn0=