#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long int LLI;

#define TRUE              (1==1)
#define FALSE             (!TRUE)
#define fo3(i,a,b)        for(i=((int)a);i<=((int)b);i++)
#define of3(i,a,b)        for(i=((int)a);i>=((int)b);i--)
#define in1(n)            scanf("%d",&(n))
#define LL1(n)            scanf("%I64d",&(n))
#define in2(n,m)          scanf("%d%d",&(n),&(m))
#define pri(n)            printf("%d\n",n)
#define prs(n)            printf("%s\n",n)
#define prL(n)            printf("%I64d\n",n)
#define strin(n)          scanf("%s",n)
#define newint(n)         (int*)calloc((n),sizeof(int))
#define arrint(ret,n,i)   fo3(i,1,n) in1(ret[i-1])
#define newLLI(n)         (LLI*)calloc((n),sizeof(LLI))
#define arrLLI(ret,n,i)   fo3(i,1,n) LL1(ret[i-1])

void fastWrite(FILE * ofp, int x) {
    int i = 12;
    char buff[i];
    buff[i] = 0;
    int neg = 0;
    if (x < 0){
        x = -x;
        neg = 1;
    }
    if (x == 0)
        buff[--i] = '0';
    else while (x != 0) {
        buff[--i] = (x % 10) + '0';
        x /= 10;
    }
    if (neg)
        buff[--i] = '-';
    fwrite(buff + i, sizeof(char), (12 - i), ofp);
}

void fastSpace(FILE * ofp){
    fwrite(" ", sizeof(char), 1, ofp);
}
void fastNewLine(FILE * ofp) {
    fwrite("\n", sizeof(char), 1, ofp);
}

typedef struct AL AL;
struct AL{
    int * vals;
    int size;
    int cap;
};
AL * ALCreate(int s) {
    AL * ret = (AL *) calloc(1, sizeof(AL));
    if (s == 0) ret->vals = NULL;
    else ret->vals = (int *) calloc(s, sizeof(int));
    ret->size = 0; ret->cap = s;
    return ret;
}
void ALAdd(AL * list, int ele) {
    if (list->cap == list->size) {
        int nC = ((list->cap << 1) | 1);
        list->vals = realloc(list->vals, sizeof(int) * nC);
        list->cap = nC;
    }
    list->vals[list->size++] = ele;
}

typedef struct Pair {
    int fi, se;
} Pair;

int comp(Pair ** arr, int f, int s) {// CHANGE THIS
    if (arr[f]->fi - arr[f]->se != arr[s]->fi - arr[s]->se)
        return (arr[s]->fi - arr[s]->se) - (arr[f]->fi - arr[f]->se);
    return 0;
}

void sort(Pair ** arr, int size) {
    int i;
    if (size < 6) {
        int nSize = 0;
        Pair * swp;
        while (size != 0) {
            nSize = 0;
            for (i = 0; i < size - 1; i++)
                if (comp(arr, i, i + 1) > 0) {
                    nSize = i + 1;
                    swp = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i + 1] = swp;
                }
            size = nSize;
        }
        return;
    }
    Pair ** tmp = (Pair **)calloc(size, sizeof(Pair *)); // CHANGE THIS
    int lSize = (size >> 1);
    int rSize = size - lSize;
    sort(arr, lSize); sort(arr + lSize, rSize);
    int lPtr = 0, rPtr = 0;
    int ptr = 0;
    while (ptr != size) {
        if (lPtr == lSize){
            tmp[ptr] = arr[lSize + (rPtr++)];
        } else if (rPtr == rSize || comp(arr, lPtr, lSize + rPtr) <= 0){ // CHANGE THIS
            tmp[ptr] = arr[lPtr++];
        } else {
            tmp[ptr] = arr[lSize + (rPtr++)];
        }
        ptr++;
    }
    for (i = 0; i < size; i++)
        arr[i] = tmp[i];
    free(tmp);
}

int bc(int x) {
    if (x <= 1)
        return x;
    return (x&1) + bc(x>>1);
}

int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}

#define MAX        100000
#define NULL_CARRY -1
#define NULL_VALUE 0

LLI h1, h2;

int carry[4 * MAX];
int st[4 * MAX];
int en[4 * MAX];
LLI ans[2][4 * MAX];

void init2(int index, int s, int e) {
   //printf("%d %d %d\n", index, s, e);
   st[index] = s;
   en[index] = e;
   ans[0][index] = 0;
   ans[1][index] = 0;
   carry[index] = NULL_CARRY;
   if (s == e)
      return;
   int mid = (s + e) >> 1;
   init2(index << 1, s, mid);
   init2((index << 1) | 1, mid + 1, e);
}

// Inclusive s and e
void ITInit(int s, int e) {
   init2(1, s, e);
}

LLI fastExpo(LLI exp, LLI base, LLI mod) {
    if (exp == 0)
        return 1;
    if (exp == 1)
        return base % mod;
    LLI tmp = fastExpo(exp >> 1, base, mod);
    tmp *= tmp;
    tmp %= mod;
    if (exp & 1)
        tmp = (tmp * base) % mod;
    return tmp;
}

LLI aoMem[2][MAX + 10];
LLI feMem[2][MAX + 10];
void genAllOnes() {
    int i;
    LLI tmp1 = 0;
    LLI tmp2 = 0;
    LLI tmp3 = 1;
    LLI tmp4 = 1;
    fo3(i,0, MAX+9) {
        aoMem[TRUE][i] = tmp1;
        tmp1 = tmp1 * 10 + 1;
        tmp1 %= h1;
        aoMem[FALSE][i] = tmp2;
        tmp2 = tmp2 * 10 + 1;
        tmp2 %= h2;
        feMem[TRUE][i] = tmp3;
        tmp3 *= 10;
        tmp3 %= h1;
        feMem[FALSE][i] = tmp4;
        tmp4 *= 10;
        tmp4 %= h2;
    }
}
LLI allOnes(int len, LLI mod) {
    return aoMem[mod==h1][len];
}

LLI agg(int pre, int suf, int pow, LLI mod) {
    LLI mult = feMem[mod==h1][pow];
    mult *= suf;
    mult += pre;
    mult %= mod;
    //printf(" returning from agg!\n");
    return mult;
}

void ITComp(int index) {
    if (carry[index] == NULL_CARRY) {
        ans[0][index] = agg(ans[0][index<<1], ans[0][(index<<1)|1], en[index<<1] - st[index<<1] + 1, h1);
        ans[1][index] = agg(ans[1][index<<1], ans[1][(index<<1)|1], en[index<<1] - st[index<<1] + 1, h2);
    } else {
        ans[0][index] = allOnes(en[index] - st[index] + 1, h1) * carry[index];
        ans[0][index] %= h1;
        ans[1][index] = allOnes(en[index] - st[index] + 1, h2) * carry[index];
        ans[1][index] %= h2;
    }
}

void push(int index) {
    if (carry[index] == NULL_CARRY)
        return;
    if (st[index] != en[index]) {
        carry[index<<1] = carry[index];
        ITComp(index<<1);
        carry[(index<<1)|1] = carry[index];
        ITComp((index<<1)|1);
    }
    carry[index] = NULL_CARRY;
}

void set2(int index, int s, int e, int value) {
    if (st[index] >= s && e >= en[index]) {
        carry[index] = value;
        ITComp(index);
        return;
    }
    if (st[index] > e || s > en[index])
        return;
    push(index);
    set2(index<<1, s, e, value);
    set2((index<<1)|1, s, e, value);
    ITComp(index);
}

void ITSet(int s, int e, int value) {
   set2(1, s, e, value);
}

LLI get2(int index, int type, int s, int e) {
    if (st[index] >= s && e >= en[index]) {
        //printf(" Starting Push!\n");
        //push(index);
        ITComp(index);
        //printf(" Out of Push!\n");
        if (type == 0) {
            //prL(agg(0, ans[type][index], st[index] - s, h1));
            return agg(0, ans[type][index], st[index] - s, h1);
        }
        return agg(0, ans[type][index], st[index] - s, h2);
    }
    if (st[index] > e || s > en[index])
        return NULL_VALUE;
    push(index);
    LLI ret = get2(index<<1, type, s, e) + get2((index<<1)|1, type, s, e);
    if (type == 0 && ret >= h1)
        ret -= h1;
    if (type == 1 && ret >= h2)
        ret -= h2;
    return ret;
}

LLI get(int type, int s, int e) {
   return get2(1, type, s, e);
}

#define MOD 1000000007

LLI ch2(int x) {
    return (x * (x - 1)) >> 1;
}

void make(int n, int spots, LLI ** mat) {
    int i, j;
    int totalSmaller = spots - 1;
    int totalBigger = n - totalSmaller;
    LLI total = ch2(n);
    fo3(i,0,spots-1) {
        fo3(j,0,spots-1) {
            int smallerCorrect = i;
            int smallerIncorrect = totalSmaller - smallerCorrect;
            int biggerIncorrect = smallerIncorrect;
            int biggerCorrect = totalBigger - biggerIncorrect;
            if (i + 1 < j || j + 1 < i)
                mat[i][j] = 0;
            else if (i == j) {
                mat[i][j] = (total - (smallerCorrect * biggerCorrect + smallerIncorrect * biggerIncorrect)) % MOD;
            } else if (j < i) {
                // Worse
                mat[i][j] = (smallerCorrect * biggerCorrect) % MOD;
            } else {
                // Better
                mat[i][j] = (smallerIncorrect * biggerIncorrect) % MOD;
            }
        }
    }
}

LLI ** ident;

void clean2(LLI ** mat, int dim) {
    int i;
    fo3(i,0,dim-1)
        free(mat[i]);
    free(mat);
}

LLI ** mult(LLI ** a, LLI ** b, int dim) {
    LLI ** ret;
    int i, j, k;
    ret = calloc(dim, sizeof(LLI*));
    fo3(i,0,dim-1){
        ret[i] = calloc(dim, sizeof(LLI));
        fo3(j,0,dim-1){
            ret[i][j] = 0;
            fo3(k,0,dim-1) {
                ret[i][j] += (a[i][k] * b[k][j]) % MOD;
            }
            ret[i][j] %= MOD;
        }
    }
    return ret;
}

LLI ** expo(LLI ** base, int pow, int dim) {
    if (pow == 0) {
        return mult(ident, ident, dim);
    }
    if (pow == 1) {
        return mult(ident, base, dim);
    }
    LLI ** tmp = expo(base, pow >> 1, dim);
    LLI ** tmp2 = mult(tmp, tmp, dim);
    clean2(tmp, dim);
    if (pow&1) {
        tmp = mult(tmp2, base, dim);
        clean2(tmp2, dim);
        tmp2 = tmp;
    }
    return tmp2;
}

LLI expo2(LLI base, int pow) {
    if (pow == 0)
        return 1;
    if (pow == 1)
        return base % MOD;
    LLI tmp = expo2(base, pow>>1);
    tmp *= tmp;
    tmp %= MOD;
    if (pow&1) {
        tmp *= base;
        tmp %= MOD;
    }
    return tmp;
}

LLI inv(LLI val) {
    if (val == 1)
        return 1;
    return MOD - ((MOD / val) * inv(MOD % val)) % MOD;
}

int main(void) {
    LLI ** orig;
    int len, pow, i, j;
    in2(len, pow);
    int arr[len];
    int cs[2];
    cs[0] = 0;
    cs[1] = 0;

    fo3(i,1,len) {
        in1(arr[i-1]);
        cs[arr[i-1]]++;
    }
    int dim = cs[0] + 1;
    if (cs[1] < cs[0])
        dim = cs[1] + 1;
    orig = calloc(dim, sizeof(LLI*));
    fo3(i,0,dim-1)
        orig[i] = calloc(dim, sizeof(LLI));
    ident = calloc(dim, sizeof(LLI*));
    fo3(i,0,dim-1){
        ident[i] = calloc(dim, sizeof(LLI));
        fo3(j,0,dim-1)
            ident[i][j] = ((i==j) ? 1 : 0);
    }
    make(len, dim, orig);

    LLI ** ret = expo(orig, pow, dim);
    clean2(orig, dim);
    int wrong = 0;
    fo3(i,0,cs[0]-1)
        if (arr[i]!=0)
            wrong++;
    int cor = dim - wrong - 1;
    LLI ans = ret[cor][dim - 1];
    clean2(ret, dim);
    LLI den = expo2(ch2(len), pow);
    //prL(ans);
    //prL(den);
    ans *= inv(den);
    ans %= MOD;
    prL(ans);
    return 0;
}


#include <stdio.h>
int main() {
	int n,m,k;
	int i;
	char a[3],b[5];
	char c[201];
	char *p;
	// 1->     -1<-
	int d;
	scanf("%d %d %d", &n, &m, &k);
	scanf("%s %s",a,b);
	scanf("%s", c);

	if(b[0] == 'h')
		d = -1;
	else
		d = 1;

	for(p=c,i=1; *p!='\0'; p++,i++) {
		if(*p=='0') {
			// move stowaway
			if(d == 1 && m-k==1 && m!=n){
				m += 1;
			}else if(d == -1 && k-m==1 && m!=1){
				m -= 1;
			}
			// move controller
			k += d;
			if(k == 1)
				d = 1;
			if(k == n)
				d = -1;
		} else {
			// move controller
			k += d;
			if(k == 1)
				d = 1;
			if(k == n)
				d = -1;
			// move stowaway
			if(d == 1) {
				if(n==2)
					m = 2;
				else if(k==1)
					m = k+2;
				else
					m = k-1;
			}else{
				if(n==2)
					m = 1;
				else if(k!=n)
					m = k+1;
				else
					m = k-2;
			}
		}

		if(k == m){
			printf("Controller %d\n",i);
			return 0;
		}
	}

	printf("Stowaway\n");

	return 0;
}


#include <stdio.h>

long long min(long long a, long long b) {
	return a < b ? a : b;
}

long long max(long long a, long long b) {
	return a > b ? a : b;
}

long long lucky(int i) {
	return i == 1 ? 0 : lucky(i / 2) * 10 + (i % 2 == 0 ? 4 : 7);
}

int main() {
	static long long aa[2047];
	int l, r, i;
	long long x, y, ans;

	scanf("%d%d", &l, &r);
	aa[0] = 4;
	for (i = 1; i < 2047; i++)
		aa[i] = lucky(i + 1);
	ans = 0;
	for (i = 0; i < 2047; i++) {
		x = max(aa[i - 1] + 1, l);
		y = min(aa[i], r);
		if (x <= y)
			ans += (y - x + 1) * aa[i];
	}
	printf("%lld\n", ans);
	return 0;
}


/* upsolve with Dukkha */
#include <stdio.h>

#define N	2000
#define MD	998244353

int ch[1 + N][1 + N];

void init(int n) {
	int i, j;

	ch[0][0] = 1;
	for (i = 1; i <= n; i++) {
		ch[i][0] = 1;
		for (j = 1; j <= i; j++)
			ch[i][j] = (ch[i - 1][j] + ch[i - 1][j - 1]) % MD;
	}
}

long long power(int a, int k) {
	long long p;

	if (k == 0)
		return 1;
	p = power(a, k / 2);
	p = p * p % MD;
	if (k % 2)
		p = p * a % MD;
	return p;
}

int main() {
	static long long pp[1 + N + N], qq[1 + N + N], aa[1 + N + N];
	int n, k, l, i, j;
	long long inv2, a;

	scanf("%d%d%d", &n, &k, &l);
	init(n);
	pp[n] = power(2, n);
	for (i = 0; i < n; i++)
		for (j = n + n; j > 0; j--)
			pp[j] = (pp[j] - pp[j - 1]) % MD;
	for (j = 0; j <= n + n; j++)
		aa[j] = pp[j];
	inv2 = (MD + 1) / 2;
	for (i = 1; i <= n - k; i++) {
		/* qq := pp / p, where p = 2x (1 - x) */
		/* divide by 2x */
		for (j = 1; j < n + n; j++)
			qq[j] = pp[j + 1] * inv2 % MD;
		qq[n + n] = 0;
		/* divide by 1 - x is multiply by 1 + x + x^2 + x^3 + ... */
		for (j = 1; j <= n + n; j++)
			qq[j] = (qq[j] + qq[j - 1]) % MD;
		/* pp := pp * (1 - p) / p = pp / p - pp = qq - pp */
		for (j = 0; j <= n + n; j++)
			pp[j] = (qq[j] - pp[j]) % MD;
		a = ch[n][i];
		for (j = 0; j <= n + n; j++)
			aa[j] = (aa[j] + a * pp[j]) % MD;
	}
	/* integrate x^i to x^{i + 1} / (i + 1) */
	a = 0;
	for (i = 0; i <= n + n; i++)
		a = (a + aa[i] * power(i + 1, MD - 2)) % MD;
	a = (a * l % MD + MD) % MD;
	printf("%lld\n", a);
	return 0;
}


#include<stdio.h>

int main()
{
    int n, x, pos;
    scanf("%d%d%d", &n, &x, &pos);

    long long low = 0, high = n, result = 1,countSmall = 0, countLarge = 0;
    long long MOD = 1e9 + 7;

    while(low<high) {
        int mid = (low + high) /2;

        if(mid == pos) low = mid + 1;
        else if(mid < pos) {
            ++countSmall;
            low = mid + 1;
        } else {
            ++countLarge;
            high = mid;
        }
    }

    int i = x-1, fact = n - countSmall - countLarge - 1;

    while(countSmall) {
        result = (result * i) % MOD;
        --i;
        --countSmall;
    }

    i = n-x;

    while(countLarge) {
        result = (result * i) % MOD;
        --i;
        --countLarge;
    }

    while(fact) {
        result = (result * fact) % MOD;
        --fact;
    }
    printf("%lld\n", result);
    return 0;
}


#include <stdio.h>

#define N	3000
#define M	3000

void slide(int *aa, int *bb, int n, int m) {
	static int qq[N];
	int i, head, cnt;

	head = cnt = 0;
	for (i = 0; i < n; i++) {
		while (cnt && aa[qq[head + cnt - 1]] > aa[i])
			cnt--;
		qq[head + cnt++] = i;
		if (i >= m - 1)
			bb[i - m + 1] = aa[qq[head]];
		if (qq[head] == i - m + 1)
			head++, cnt--;
	}
}

int main() {
	static int aa[N][M], bb[N][M], cc[N], dd[N];
	int n, m, a, b, g, x, y, z, i, j;
	long long ans;

	scanf("%d%d%d%d%d%d%d%d", &n, &m, &a, &b, &g, &x, &y, &z);
	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++) {
			aa[i][j] = g;
			g = ((long long) g * x + y) % z;
		}
	for (i = 0; i < n; i++)
		slide(aa[i], bb[i], m, b);
	ans = 0;
	for (j = 0; j + b <= m; j++) {
		for (i = 0; i < n; i++)
			cc[i] = bb[i][j];
		slide(cc, dd, n, a);
		for (i = 0; i + a <= n; i++)
			ans += dd[i];
	}
	printf("%lld\n", ans);
	return 0;
}


#include <stdio.h>
#include <string.h>

int main(){
    int i, num, flag=0;
    char str[11];
    scanf("%s", str);
    num = strlen(str);
    if(num == 1){
        if(str[0] == '3' || str[0] == '7'){
            printf("Yes\n");
        }
        else
            printf("No\n");
    }
    else{
        for(i=0; i<num/2; i++){
            if(str[i] == '1' || str[i] == '2'){
                printf("No\n");
                flag = 1;
                break;
            }
            if(str[i] == '0'){
                if(str[num-i-1] != '8'){
                    printf("No\n");
                    flag = 1;
                    break;
                }
            }
            if(str[i] == '3'){
                if(str[num-i-1] != '3'){
                    printf("No\n");
                    flag = 1;
                    break;
                }
            }
            if(str[i] == '4'){
                if(str[num-i-1] != '6'){
                    printf("No\n");
                    flag = 1;
                    break;
                }
            }
            if(str[i] == '5'){
                if(str[num-i-1] != '9'){
                    printf("No\n");
                    flag = 1;
                    break;
                }
            }
            if(str[i] == '6'){
                if(str[num-i-1] != '4'){
                    printf("No\n");
                    flag = 1;
                    break;
                }
            }
            if(str[i] == '7'){
                if(str[num-i-1] != '7'){
                    printf("No\n");
                    flag = 1;
                    break;
                }
            }
            if(str[i] == '8'){
                if(str[num-i-1] != '0'){
                    printf("No\n");
                    flag = 1;
                    break;
                }
            }
            if(str[i] == '9'){
                if(str[num-i-1] != '5'){
                    printf("No\n");
                    flag = 1;
                    break;
                }
            }
        }
        if(num%2 == 1 && flag == 0){
            if(str[num/2] == '0' || str[num/2] == '1' || str[num/2] == '2' || str[num/2] == '4' || str[num/2] == '5' || str[num/2] == '6' || str[num/2] == '8' || str[num/2] == '9'){
                printf("No\n");
                flag = 1;
            }
        }
        if(flag == 0){
            printf("Yes\n");
        }
    }
    return 0;
}


#include <stdio.h>

int mod_inv(int a, int p){
	int y = p-2;
	int res = 1;
	while(y!=0){
		if(y&1){
			res = ((long long)res * a)%p;
		}
		a = ((long long)a*a)%p;
		y = y>>1;
	}
	return res;
}

int main(void) {
	// your code goes here
	int n,c,i;
	scanf("%d %d",&n,&c);
	int res = c;
	int prev = c;
	int p = 1000003;
	for(i=2; i<=n ;i++){
		prev = ((((long long)(c+i-1)*prev)%p)*mod_inv(i,p))%p;
		res = (res + prev)%p;
	}
	printf("%d\n",res);
	return 0;
}


#include<stdio.h>
#define mod 1000000007
long long a=1;
long long crazy(long long sayi,long long us){
	if(us==0)
	return 1;
	if(us%2==1)
	return a=((sayi%mod)*(crazy(sayi,us-1)%mod))%mod;
	if(us%2==0){
	long long temp=crazy(sayi,us/2)%mod;
	return a=(temp*temp)%mod;
	}
}
int main(){
	long long n,cikti;
	scanf("%lld",&n);
	cikti=(crazy(2,n))*(crazy(2,n)+1);
	printf("%lld",(cikti/2)%mod);
	return 0;
}