#include using namespace std; #define LL __int64 #define ll __int64 typedef pair pii; template< typename T > inline void read(T &x) { static char _c; static bool _f; x = 0; _f = 0; _c = getchar(); while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();} while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();} if(_f) x = -x; } template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;} template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;} #define lowbit(x) ((x) & -(x)) #define lson l,mid,id<<1 #define rson mid+1,r,id<<1|1 #define ls id<<1 #define rs id<<1|1 #define MID(l,r) ((l)+(((r)-(l))>>1)) #define fi first #define se second #define mk make_pair #define pb push_back const int MOD = (int) 1e9 + 7; //const int MOD = (int) 998244353; const int maxn = (int) 1e5 + 20; const int maxm = (int) 1e7 + 20; const double pi = (double) acos(-1.0); LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;} LL n, a, b; struct Big { LL a[128]; Big() {memset(a, 0, sizeof(a));} Big(LL x) { memset(a, 0, sizeof(a)); int cnt = 0; while(x) { a[cnt++] = x % 10; x /= 10; } } void show() { int len = 0; for(int i = 0; i < 128; i++) if(a[i]) len = i; for(int i = len; ~i; i--) cout < y.a[i]) return y; if(x.a[i] < y.a[i]) return x; } return x; } Big N, A, B; Big dfs(LL n) { if(n & 1) { Big res; res = Big(n) * Big(n) * Big(n) * Big(b) + Big(n - 1) * Big(n) * Big(n) * Big(a); return res; } else { Big x, y; x = Big(n) * Big(n) * Big(n) * Big(b) + Big(n - 1) * Big(n) * Big(n) * Big(a); y = Big(18) * Big(n / 2) * Big(n / 2) * Big(a) + Big(7) * dfs(n / 2); return Min(x, y); } } void work() { cin >>n; cin >>a >>b; Big res = dfs(n); LL ans = 0; for(int i = 127; ~i; i--) { ans = (ans * 10 + res.a[i]) % MOD; } cout <