import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.StringTokenizer;

public class Main {

	private static final long MOD = 1000000007;

	private void solve() throws IOException {
		long ans = f(nextLong());
		ans = (ans * (ans + 1) >> 1) % MOD;
		out.println(ans);
	}

	private long f(long n) {
		if (n == 0)
			return 1;
		if (n == 1)
			return 2;
		if (n % 2 == 0) {
			long k = f(n >> 1);
			return (k * k) % MOD;
		} else {
			return (f(n - 1) << 1) % MOD;
		}
	}

	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;

	private Main() throws IOException {
		Locale.setDefault(Locale.US);
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		eat("");
		solve();
		in.close();
		out.close();
	}

	String next() throws IOException {
		while (!st.hasMoreTokens()) {
			String line;
			line = in.readLine();
			if (line == null) {
				return null;
			}
			eat(line);
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	private void eat(String s) {
		st = new StringTokenizer(s);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main (String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader (inputStream);
		PrintWriter out = new PrintWriter (outputStream);
		TaskC solver = new TaskC ();
		solver.solve (1, in, out);
		out.close ();
	}

	static class TaskC {
		private long mp2 (long n) {
			long p;
			if (n == 0) return 1;
			p = mp2 (n/2);
			p = (p*p)%(1000000007);
			if (n%2 != 0) p = (p*2)%(1000000007);
			return p;
		}

		public void solve (int testNumber, InputReader in, PrintWriter out) {
//every triangle generates three same faced triangle and one opposite faced triangle
//remember pow must be written in logn
			long n = in.nextLong ();
			if (n == 0) {
				out.println ("1");
				return;
			}
//down=3*down+up at each step;
//up=3*up+down at each step;
//1,0 3,1, 10,6, 36,28 at each step the difference become double
//4^n/2+2^(n-1) is the answer!!! ALHAMDULILLAH!
//time complexity can be o(logn) highest
			long res1 = mp2 (n-1);
//4^n/2 =2^(2n-1)=2^n*2^(n-1);
			long res = res1*2;
			res %= InputReader.inf;
			res = (res*res1)%InputReader.inf;
			res += res1;
			res %= InputReader.inf;
			out.println (res);
		}

	}

	static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;
		public static final int inf = 1000000007;

		public InputReader (InputStream stream) {
			reader = new BufferedReader (new InputStreamReader (stream), 32768);
			tokenizer = null;
		}

		public String next () {
			while (tokenizer == null || !tokenizer.hasMoreTokens ()) {
				try {
					String str;
					if ((str = reader.readLine ()) != null) tokenizer = new StringTokenizer (str);
					else return null;//to detect eof
				} catch (IOException e) {
					throw new RuntimeException (e);
				}
			}
			return tokenizer.nextToken ();
		}

		public long nextLong () {
			return Long.parseLong (next ());
		}

	}
}

import java.util.*;

public class Main
{
    static long pow(long exponent)
    {
        if(exponent==0)
            return 1;
        if(exponent%2==0)
        {
            long x=pow(exponent/2)%MOD;
            return (x*x)%MOD;
        }
        return (2*pow(exponent-1))%MOD;
    }
    static final long MOD=1_000_000_007;
	public static void main(String args[]) throws Exception
	{
		Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        if(n==0)
            System.out.println(1);
        else
            System.out.println((pow(n-1)*(pow(n)+1))%MOD);
	}
}

import java.io.*;
import java.util.*;

public class Plant {
    public static void main(String[] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        long n = Long.parseLong(f.readLine());
        long mod = 1000000007;
        if (n == 0)
            System.out.println(1);
        else
            System.out.println((pow(2,(2*n-1)%(mod-1),mod) + pow(2,(n-1)%(mod-1),mod)) % mod);
    }

    public static long pow(long a, long n, long mod)
    {
        if (n == 0)
            return 1;
        long b = pow(a, n/2, mod);
        b = (b*b) % mod;
        if (n % 2 == 1)
            b = (b*a) % mod;
        return b;
    }
}

import java.math.BigInteger;
import java.util.Scanner;

public class C {

    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        BigInteger e1 = BigInteger.valueOf(n);
        BigInteger e2 = BigInteger.valueOf(n-1);
        BigInteger m = BigInteger.valueOf(1000000007);
        System.out.println(BigInteger.valueOf(2).modPow(e2, m).multiply(BigInteger.valueOf(1).add(BigInteger.valueOf(2).modPow(e1, m))).mod(m));
    }
}

import java.util.*;
import java.math.*;
import java.io.*;

public class Main
	{
	public static void main(String args[]) throws IOException
		{
		//BufferedReader c=new BufferedReader(new InputStreamReader(System.in));
		Scanner c=new Scanner(System.in);
		BigInteger n=new BigInteger(c.nextLine());
		BigInteger two=new BigInteger("2");
		BigInteger one=new BigInteger("1");
		BigInteger mod=new BigInteger("1000000007");
		BigInteger ans1=two.modPow(n.subtract(one),mod);
		BigInteger ans2=two.modPow(n,mod);
		ans2=ans2.add(one);
		//System.out.println(ans1+" "+ans2);
		ans1=ans1.multiply(ans2);
		ans1=ans1.mod(mod);
		System.out.println(ans1);
		}
	}

//must declare new classes here

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class C {

	static long mod = 1000000007L;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		long n = Long.parseLong(br.readLine());
		BigInteger modpow = BigInteger.valueOf(2).modPow(BigInteger.valueOf(n),
				BigInteger.valueOf(mod));
		n = Long.parseLong(modpow.toString());
		n %= mod;
		long no = (n + 1) % mod;
		n = ((n * no) / 2) % mod;
		out.println(n);
		out.close();
	}
}

import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

public class Main{

	public static void main(String[] args) throws Exception {

		long n = Long.parseLong(inB.readLine());
		final int MOD = 1000000007;
		BigInteger bi2 = new BigInteger("2");
		bi2 = bi2.modPow(new BigInteger(Long.toString(n*2 - 1)), new BigInteger(Integer.toString(MOD)));
		BigInteger bi1 = new BigInteger("2");
		bi1 = bi1.modPow(new BigInteger(Long.toString(n - 1)), new BigInteger(Integer.toString(MOD)));
		exit(bi1.add(bi2).mod(new BigInteger(Integer.toString(MOD))));
	}

	private static PrintWriter out =  new PrintWriter(System.out);;
	private static BufferedReader inB = new BufferedReader(new InputStreamReader(System.in));
	private static StreamTokenizer in = new StreamTokenizer(inB);

	private static void exit(Object o) throws Exception {
		out.println(o);
		out.flush();
		System.exit(0);
	}
	private static void println(Object o) throws Exception{
		out.println(o);
		out.flush();
	}
	private static void print(Object o) throws Exception{
		out.print(o);
		out.flush();
	}
	private static int nextInt() throws Exception {
		in.nextToken();
		return (int)in.nval;
	}
	private static String nextString() throws Exception {
		in.nextToken();
		return in.sval;
	}
}

import java.util.Scanner;

public class WorkFile {
    public static long pow(long n) {
        if (n==0) return 1;
        else if (n==1) return 2;
        else if (n%2==0) {
            long x = pow(n/2);
            return x*x%1000000007;
        }
        else {
            long x = pow(n/2);
            return x*x*2%1000000007;
        }
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        System.out.println(pow(n)*(pow(n)+1)/2%1000000007);
    }
}

import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
    static class Reader
    {
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;}
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];}
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;}
        public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();}
        public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;}
        public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;}
        public double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; }
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; }
        public int[] arr(int n){int[] ret = new int[n];for (int i = 0; i < n; i++) {ret[i] = i();}return ret;}
    }

           //       |----|       /\      |    |   -----   |
           //       |   /       /  \     |    |     |     |
           //       |--/       /----\    |----|     |     |
           //       |   \     /      \   |    |     |     |
           //       |    \   /        \  |    |   -----   -------

    static int n,m;
    static long power(long x,long y,long p)
    {
        long res = 1;
        x = x % p;
        while (y > 0)
        {
            if((y & 1)==1)
                res = (res * x) % p;
            y = y >> 1;
            x = (x * x) % p;
        }
        return res;
    }
    public static void main(String[] args)throws IOException
    {
        PrintWriter out= new PrintWriter(System.out);
        Reader sc=new Reader();
        //OEIS ZINDABAD
        long n=sc.l();
        if(n==0)
        {
            System.out.println(1);
            System.exit(0);
        }
        long p1=power(2,n-1,1000000007l);
        long p2=power(2,n,1000000007l);
        out.println((p1*(1+p2))%1000000007);
        out.flush();
    }
}

import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

public class C118 {
        public static void main(String[] args) {
                InputStream inputStream = System.in;
                OutputStream outputStream = System.out;
                InputReader in = new InputReader(inputStream);
                PrintWriter out = new PrintWriter(outputStream);
                CodeC118 solver = new CodeC118();
                solver.solve(1, in, out);
				//long n=(long)100000000*(long)100000000;
				//out.println(solver.convert(n)+" for "+n);
                out.close();
        }
}

class CodeC118
{
public void solve(int testNumber, InputReader in, PrintWriter out)
{
	long mod=1000000007;
	long n=in.nextLong();
	long ans=0;
	if(n!=0)
	{
		ans = (pow(2*n-1)%mod+pow(n-1)%mod)%mod;
	}
	else
	{
		ans=1;
	}
	out.println(ans);
}
public long pow(long p)
{
	if(p==0)
	{
		return 1;
	}
	long mod=1000000007;
	long ret=1;
	long arr[]=new long[75];
	arr[0]=2;
	for(int i=1;i<arr.length;i++)
	{
		arr[i]=(arr[i-1]*arr[i-1])%mod;
	}
	String s=convert(p);
	// System.out.println(s);
	for(int i=0;i<s.length();i++)
	{
		if(s.charAt(i)=='1')
		{
			ret=(ret*arr[s.length()-i-1])%mod;
		}
	}
	return ret;
}
public String convert(long n)
{
	//System.out.println("Read "+n);
	String num="";
	long t=0;
	while(n!=0)
	{
		num=String.valueOf(n%2)+num;
		//System.out.println(num);
		n/=2;
		t++;
	}
	return num;
	}
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }
	public void inputShuffleArrayInt(int arr[])
	{
		int l=arr.length;
		for(int i=0;i<l;i++)
		{
			if(i%2==0)
			{
				arr[i/2]=nextInt();
			}
			else
			{
				arr[l-((i+1)/2)]=nextInt();
			}
		}
	}

    }

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Plant {

	static final long MOD = (long) 1e9 + 7;

	static long[][] MatrixMult(long[][] a, long[][] b) {
		long[][] res = new long[2][2];
		for (int i = 0; i < 2; i++)
			for (int j = 0; j < 2; j++)
				for (int k = 0; k < 2; k++)
					res[i][j] = (res[i][j] + (a[i][k] * b[k][j]) % MOD) % MOD;
		return res;
	}

	static long[][] MatrixExpo(long[][] base, long exp) {
		if (exp == 1)
			return base;
		long[][] x = MatrixExpo(base, exp >> 1);
		if ((exp & 1) == 0)
			return MatrixMult(x, x);
		return MatrixMult(base, MatrixMult(x, x));
	}

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		long n = sc.nextLong();
		if (n == 0)
			out.println(1);
		else if (n == 1)
			out.println(3);
		else {
			long[][] ans = { { 3, 1 }, { 1, 3 } };
			ans = MatrixExpo(ans, n);
			out.println(ans[0][0]);
		}
		out.close();
	}

	static class MyScanner {

		BufferedReader br;
		StringTokenizer st;

		MyScanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}

import java.util.*;
public class Plant {
	public static long MOD = 1000000007;
	public static void main(String[] Args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		n = pow(n);
		n %= MOD;
		n *= n+1;
		n /= 2;
		n %= MOD;
		System.out.println(n);
	}
	public static long pow(long n){
		if(n==0)
			return 1;
		long t = pow(n/2);
		t = t*t;
		t = t%MOD;
		if(n%2==1)
			t = (t*2)%MOD;
		return t;
	}
}

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.InputMismatchException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author alex
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
    private static final long MOD = (long) (1e9 + 7);

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        long n = in.readLong();
        if (n==0) {
            out.println(1);
            return;
        }
        long ans = (pow(2, n - 1) % MOD * ((pow(2, n) + 1) % MOD)) % MOD;
        out.println(ans);
    }

    private long pow(long b, long e) {
        if (e == 0 ) return 1;
        if (e % 2 == 0) {
            long ret = pow(b, e >> 1) % MOD;
            return ret * ret % MOD;
        } else {
            return b * pow(b, e - 1) % MOD;
        }
    }
}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public long readLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    }

import java.io.*;
import java.util.*;
import java.lang.*;
    public class templ {
        public static int a[]=new int[1000000];
    int binarySearch(long arr[], int l, int r, long x)
    {
        if (r >= l)
        {
            int mid = l + (r - l)/2;
            if (arr[mid] == x)
            return mid;
            if (arr[mid] > x)
            return binarySearch(arr, l, mid-1, x);
            return binarySearch(arr, mid+1, r, x);
        }
        return -1;
    }
    int partition(int arr[],int a[], int low, int high)
    {
        int pivot = arr[high];
        int i = (low-1);
        for (int j=low; j<high; j++)
        {
            if (arr[j] <= pivot)
            {
                i++;
                int temp = arr[i];
                arr[i] = arr[j];
                arr[j] = temp;
                temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
        }
        int temp = arr[i+1];
        arr[i+1] = arr[high];
        arr[high] = temp;
        temp = a[i+1];
        a[i+1] = a[high];
        a[high] = temp;

        return i+1;
    }
    void sort(int arr[],int a[], int low, int high)
    {
        if (low < high)
        {
            int pi = partition(arr,a, low, high);
            sort(arr, a,low, pi-1);
            sort(arr,a, pi+1, high);
        }
    }
    long power(int x,long y,long m)
    {
        if(y==1)
            return(x);
        if(y==0)
            return(1);
        long p=power(x,y/2,m)%m;
        if(y%2==0)
            return((p*p)%m);
        else
            return((x*p*p)%m);
    }
    public static void main(String[] args) throws FileNotFoundException {
     try
     {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        templ ob=new templ();
        long n=in.nextLong();
        if(n==0)
            out.println("1");
        else
        {
            long x;
            long m=1000000007;
            x=ob.power(2,n-1,m);
            long ans=((((x)%m)*((2*x+1)%m))%m);
            out.println(ans);
        }
        out.close();
    }
        catch(Exception e){
        return;
    }
    }
    static class InputReader {

        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String nextLine() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndOfLine(c));
            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }

    }
}

import java.util.*;
import java.io.*;

public class Solution {
	FastScanner in;
	PrintWriter out;

	final long MAX = 1000000007;

	long binpow (long a, long n) {
		if (n == 0)
			return 1;
		if (n % 2 == 1)
			return ((binpow (a, n-1) % MAX) * a) % MAX;
		else {
			long b = binpow (a, n/2) % MAX;
			return (b * b) % MAX;
		}
	}

	public void solve() throws IOException {
		long N = in.nextLong();
		long ans;
		if (N == 0) ans = 1; else ans = (binpow(2, N - 1) % MAX) * ((1 + binpow(2, N)) % MAX);
		out.println(ans % MAX);
	}

	public void run() {
		try {
			//in = new FastScanner(new File("input.txt"));
			//out = new PrintWriter(new File("output.txt"));

			in = new FastScanner(System.in);
			out = new PrintWriter(System.out);

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

	public static void main(String[] arg) {
		new Solution().run();
	}
}

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

    public class Test {
            public static void main(String args[]){
            	Scanner input = new Scanner(System.in);
                   	String s = input.nextLine();
                    maximum(s);
            }

          public static void maximum(String s){
        	  BigInteger a = new BigInteger(s);
        	  BigInteger b = new BigInteger("2");
        	  BigInteger mode = new BigInteger("1000000007");
        	  BigInteger d = new BigInteger("1");
        	  //BigInteger c = b.modPow(a,mode);
        	  BigInteger cs = b.modPow(a,mode);
        	  //System.out.println((c.multiply(c.add(d))).divide(b));
        	  if(cs.multiply(cs.add(d)).compareTo(d) <= 0){
            	  System.out.println(cs.multiply(cs.add(d)).mod(mode));
        	  }else{
        		  System.out.println(cs.multiply(cs.add(d)).divide(b).mod(mode));
        	  }

            	  //1000000007
          }

    }

import java.util.*;

public class Main {
    public static long mod = 1000000007;

    public static long modpow(long b, long e, long m) {
        b %= m;
        long res = 1;
        while(e > 0) {
            if((e & 1) != 0) res = (res * b) % m;
            b = (b * b) % m;
            e >>= 1;
        }
        return res;
    }

    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()) {
            long n = sc.nextLong();
            if(n == 0) System.out.println("1");
            else {
                long temp1 = (n-1) % (mod - 1);
                long s1 = modpow(2, temp1, mod);
                long temp2 = (2*n-1) % (mod - 1);
                long s2 = modpow(2, temp2, mod);
                System.out.println((s1+s2) % mod);
            }
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;

public class Task185A {

	public static void main(String... args) throws NumberFormatException,
			IOException {
		Solution.main(System.in, System.out);
	}

	static class Scanner {

		private final BufferedReader br;
		private String[] cache;
		private int cacheIndex;

		Scanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
			cache = new String[0];
			cacheIndex = 0;
		}

		int nextInt() throws IOException {
			if (cacheIndex >= cache.length) {
				cache = br.readLine().split(" ");
				cacheIndex = 0;
			}
			return Integer.parseInt(cache[cacheIndex++]);
		}

		long nextLong() throws IOException {
			if (cacheIndex >= cache.length) {
				cache = br.readLine().split(" ");
				cacheIndex = 0;
			}
			return Long.parseLong(cache[cacheIndex++]);
		}

		String next() throws IOException {
			if (cacheIndex >= cache.length) {
				cache = br.readLine().split(" ");
				cacheIndex = 0;
			}
			return cache[cacheIndex++];
		}

		void close() throws IOException {
			br.close();
		}

	}

	static class Solution {

		private static long fast_pow(long a, long n) {
			long result = 1;
			long power = n;
			long value = a;
			while (power > 0) {
				if (power % 2 == 1) {
					result = result * value;
					result = result % 1000000007;
				}
				value = value * value;
				value = value % 1000000007;
				power /= 2;
			}
			return result;
		}

		public static void main(InputStream is, OutputStream os)
				throws NumberFormatException, IOException {
			PrintWriter pw = new PrintWriter(os);
			Scanner sc = new Scanner(is);

			long n = sc.nextLong();

			long podstawa = fast_pow(2, n);

			pw.println((podstawa * (podstawa + 1) / 2) % 1000000007);

			pw.flush();
			sc.close();
		}
	}

}

import java.math.BigInteger;
import java.util.Scanner;

public class A185B {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        BigInteger a;
        BigInteger MOD = BigInteger.valueOf(1000000007);
        a = BigInteger.valueOf(2).modPow(BigInteger.valueOf(n), MOD)
                .add(BigInteger.ONE);
        a = a.multiply(
                BigInteger.valueOf(2).modPow(BigInteger.valueOf(n - 1), MOD))
                .mod(MOD);
        System.out.println(a);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        // TODO Auto-generated method stub
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);
        //BufferedReader in = new BufferedReader(new FileReader("input.txt"));
        //PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
        long n=Long.parseLong(in.readLine());
        int mod=1000000007;
        n%=500000003;
        if(n==0){
            out.println(1);
        }
        else{
            n--;
            long f=1;
            for(int i=1; i<=n/30; i++){
                f*=32768*32768;
                f%=mod;
            }
            for(int i=1; i<=n%30; i++){
                f*=2;
                f%=mod;
            }

            out.println(f*(f*2+1)%mod);
        }

        out.close();
    }
}

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CF {
	static long mod = 1000000007;

	public static void main(String[] args) throws Exception {
		FastScanner sc = new FastScanner(System.in);
		long N = sc.nextLong();
		long[][] matrix = new long[2][2];
		matrix[0][0]=3;
		matrix[1][1]=3;
		matrix[1][0]=1;
		matrix[0][1]=1;
		long[][] res = fastExpo(matrix, N);
		System.out.println(res[0][0]);
	}

	private static int fix(char charAt) {
		if (Character.isLowerCase(charAt))
			return charAt - 'a';
		return charAt - 'A' + 26;
	}

	public static long[][] fastExpo(long[][] m, long pow) {
		if (pow == 0) {
			long[][] i = new long[m.length][m.length];
			for (int t = 0; t < i.length; t++)
				i[t][t] = 1;
			return i;
		}
		if (pow % 2 == 1)
			return mult(m, fastExpo(m, pow - 1));
		long[][] temp = fastExpo(m, pow / 2);
		return mult(temp, temp);
	}

	public static long[][] mult(long[][] a, long[][] b) {
		long[][] x = new long[a.length][b[0].length];
		for (int r = 0; r < x.length; r++)
			for (int c = 0; c < x[r].length; c++)
				for (int i = 0; i < a[0].length; i++) {
					x[r][c] += a[r][i] * b[i][c];
					x[r][c] %= mod;
				}
		return x;
	}

	static class FastScanner {

		BufferedReader br;

		StringTokenizer st;

		public FastScanner(InputStream in) throws Exception {

			br = new BufferedReader(new InputStreamReader(in));

			st = new StringTokenizer(br.readLine().trim());

		}

		public int numTokens() throws Exception {

			if (!st.hasMoreTokens()) {

				st = new StringTokenizer(br.readLine().trim());

				return numTokens();

			}

			return st.countTokens();

		}

		public String next() throws Exception {

			if (!st.hasMoreTokens()) {

				st = new StringTokenizer(br.readLine().trim());

				return next();

			}

			return st.nextToken();

		}

		public double nextDouble() throws Exception {

			return Double.parseDouble(next());

		}

		public float nextFloat() throws Exception {

			return Float.parseFloat(next());

		}

		public long nextLong() throws Exception {

			return Long.parseLong(next());

		}

		public int nextInt() throws Exception {

			return Integer.parseInt(next());

		}

		public String nextLine() throws Exception {

			return br.readLine().trim();

		}

	}

}

import java.util.*;
import java.io.*;

public class prob {

    static Scanner sc;
    static PrintWriter pw;
    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static final int mod = 1000000007;

    static int binpow (long n) {
        if (n == 0)
            return 1;
        if (n % 2 == 1)
            return binpow (n-1) * 2 % mod;
        else {
            int b = binpow (n/2);
            return (int)((long)b * b % mod);
        }
    }

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        pw = new PrintWriter(System.out);

        try{
            final long n = sc.nextLong();
            final long r = binpow(n - 1);
            final long w = r * 2 % mod + 1;

            if(n == 0)
                pw.println(1);
            else
                pw.println((r * w) % mod);

        }
        finally {
            pw.close();
        }
    }

    static int nextInt() throws Exception {
        in.nextToken();
        return (int) in.nval;
    }
    static double nextDouble() throws Exception {
        in.nextToken();
        return in.nval;
    }
    public static long nextLong() throws Exception {
        in.nextToken();
        return (long)in.nval;
    }
    public static String nextString() throws Exception {
        in.nextToken();
        return in.sval;
    }
}

import java.math.BigInteger;
import java.util.Scanner;
public class cf185a {
  static long mod = 1000000007;
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    long n = in.nextLong();
    long ans = (pow(4,n)+pow(2,n))%mod;
    long inv = BigInteger.valueOf(2).modInverse(BigInteger.valueOf(mod)).longValue();
    ans = (ans*inv)%mod;
    System.out.println(ans);
  }
  static long pow(long x, long p) {
    if(p == 0) return 1;
    long tmp = pow(x,p>>1);
    tmp = (tmp*tmp)%mod;
    if((p&1)==1) tmp = (tmp*x)%mod;
    return tmp;
  }
}

import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Jitendra Kushwaha
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}
}

class Task {
    public void solve(int testNumber, FastScanner in, PrintWriter out) {
        long i = in.nextLong();
        final int MOD = 1000000007;
        BigInteger den = BigInteger.valueOf(2).modInverse(BigInteger.valueOf(MOD));

        BigInteger num = BigInteger.valueOf(2).modPow(BigInteger.valueOf(i), BigInteger.valueOf(MOD));
        num = num.multiply(num.add(BigInteger.ONE));
        num.mod(BigInteger.valueOf(MOD));

        long res = num.multiply(den).mod(BigInteger.valueOf(MOD)).longValue();
        out.print(res);

    }
}

class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    public FastScanner(InputStream stream) {
        br = new BufferedReader(new InputStreamReader(stream));
    }

    public String nextToken() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    public long nextLong() {
        return Long.parseLong(nextToken());
    }

}

import java.math.BigInteger;
import java.util.Scanner;

public class CF186C {

    final static BigInteger MOD = BigInteger.valueOf(1000000007L);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigInteger n = sc.nextBigInteger();
        BigInteger nMinusOne = n.subtract(BigInteger.ONE);
        final BigInteger TWO = BigInteger.valueOf(2);
        long ans = BigInteger.valueOf(4).modPow(nMinusOne, MOD).multiply(TWO).add(
                BigInteger.valueOf(2).modPow(nMinusOne, MOD)).mod(MOD).longValue();
        System.out.println(ans);
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        // TODO Auto-generated method stub
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);
        //BufferedReader in = new BufferedReader(new FileReader("input.txt"));
        //PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
        long n=Long.parseLong(in.readLine());
        int mod=1000000007;
        n%=500000003;
        if(n==0){
            out.println(1);
        }
        else{
            n--;
            long f=1;
            for(int i=1; i<=n/20; i++){
                f*=1024*1024;
                f%=mod;
            }
            for(int i=1; i<=n%20; i++){
                f*=2;
                f%=mod;
            }

            out.println(f*(f*2+1)%mod);
        }

        out.close();
    }
}

import java.util.*;
import java.math.*;
 public class triangle {

   public static void main(String[] args){
   Scanner userinput  = new Scanner(System.in);
   String a = userinput.nextLine();
   BigInteger two = new BigInteger("2");
   BigInteger one = new BigInteger("1");
   BigInteger n = new BigInteger(a);
   BigInteger n1 = n.subtract(one);
   BigInteger n2 = (n.multiply(two)).subtract(one);

   BigInteger num = new BigInteger("1000000007");
   BigInteger a1 = two.modPow(n1,num);
   BigInteger a2 = two.modPow(n2,num);
   BigInteger a3 = (a1.add(a2)).mod(num);
   System.out.println(a3);
   }

}

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Main {
	static BufferedReader br;
	static StringTokenizer st;
	static PrintWriter pw;

	public static void main(String[] args) throws IOException	{
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		//185A: 2^(n-1)*(1+2^n)
		long n = readLong();
		if(n==0)
			pw.println(1);
		else	{
			long a = pow(2, n-1, 1000000007);
			long b = 1 + pow(2, n, 1000000007);
			pw.println((a*b)%1000000007);
		}
		pw.close();
	}

	public static long pow(long b, long e, long m)	{
		long r = 1;
		while(e > 0)	{
			if(e%2==1)	{
				r *= b;
				r %= m;
			}
			b *= b;
			b %= m;
			e >>= 1;
		}
		return r;
	}

	public static long readLong() throws IOException	{
		return Long.parseLong(nextToken());
	}
	public static double readDouble() throws IOException	{
		return Double.parseDouble(nextToken());
	}
	public static int readInt() throws IOException	{
		return Integer.parseInt(nextToken());
	}
	public static short readShort() throws IOException	{
		return Short.parseShort(nextToken());
	}
	public static String nextToken() throws IOException	{
		while(st == null || !st.hasMoreTokens())	{
			if(!br.ready())	{
				pw.close();
				System.exit(0);
			}
			st = new StringTokenizer(br.readLine());
		}
		return st.nextToken();
	}
}

import java.io.*;
import java.util.*;
import java.math.*;

public class A implements Runnable {
	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;
	Random rnd;

	final long mod = 1000000007;

	long pow(long a, long p) {
		long res = 1;

		while(p > 0) {
			if(p % 2 == 1) {
				res *= a;
				res %= mod;
			}

			a *= a;
			a %= mod;
			p /= 2;
		}

		return res;
	}

	void solve() throws IOException {
		long n = nextLong();

		if(n == 0) {
			out.println(1);
			return;
		}

		/*long a = 1, b = 0;

		for(int it = 0; it < n; it++) {
			long newA = 3 * a + b, newB = 3 * b + a;
			a = newA;
			b = newB;
		}*/

		long res = pow(2, n - 1) * (1 + pow(2, n));
		res %= mod;

		while(res < 0) {
			res += mod;
		}

		out.println(res);
	}

	public static void main(String[] args) {
		final boolean oldChecker = false;

		if(oldChecker) {
			new Thread(null, new A(), "yarrr", 1 << 24).start();
		} else {

			new A().run();
		}
	}

	public void run() {
		try {
			final String className = this.getClass().getName().toLowerCase();

			try {
				in = new BufferedReader(new FileReader(className + ".in"));
				out = new PrintWriter(new FileWriter(className + ".out"));
			} catch (FileNotFoundException e) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(42);
		}
	}

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null) {
				return null;
			}

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

import java.util.Scanner;

public class C {

    static int p = 1000000007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int[][]a = new int[3][3];
        a[1][1] = 3;a[1][2] = 1; a[2][1] = 1;a[2][2] = 3;
        int[][]b = new int[3][3];
        b[1][1] = b[2][2] = 1;
        while (n > 0) {
            if ((n & 1)==1) {
                b = MatrixMultiple(b, a);
            }
            n >>= 1;
            a = MatrixMultiple(a, a);
        }
        System.out.println(b[1][1]);
    }

    private static int[][] MatrixMultiple(int[][] a, int[][] b) {
        int[][]c = new int[3][3];
        for (int i = 1; i <= 2; i++) {
            for (int j = 1; j <= 2; j++) {
                for (int j2 = 1; j2 <= 2; j2++) {
                    c[i][j] = (c[i][j]+(int)(((long)a[i][j2]*b[j2][j]) % p)) % p;
                }
            }
        }
        return c;
    }
}

import java.io.PrintStream;
import java.util.Scanner;

/**
 * @author Roman Elizarov
 */
public class Round_118_A {
	private static final long MOD = 1000000007;

	public static void main(String[] args) {
		new Round_118_A().go();
	}

	long n;

	void go() {
		// read input
		Scanner in = new Scanner(System.in);
		n = in.nextLong();

		// solve
		long result = solve();

		// write result
		PrintStream out = System.out;
		out.println(result);
	}

	long solve() {
		long p = n;
		long ca = 1;
		long cb = 0;
		long ma = 3;
		long mb = 1;
		// inv: C * M^p
		while (p > 0) {
			if (p % 2 != 0) {
				long da = (ca * ma + cb * mb) % MOD;
				long db = (ca * mb + cb * ma) % MOD;
				ca = da;
				cb = db;
			}
			if (p > 1) {
				long da = (ma * ma + mb * mb) % MOD;
				long db = (ma * mb + mb * ma) % MOD;
				ma = da;
				mb = db;
			}
			p /= 2;
		}
		return ca;
	}
}

import java.math.BigInteger;
import java.util.Scanner;

public class prime_less {
    public static void main(String[] args)  throws Exception{
        new prime_less().run(args);

    }

    private void run(String[] args) throws Exception{
        Scanner input = new Scanner(System.in);
        BigInteger n = input.nextBigInteger();
        BigInteger p = BigInteger.valueOf(2);
        BigInteger m = BigInteger.valueOf(1000000007);
        BigInteger ret = p.modPow(n, m).add(BigInteger.ONE);
        ret = ret.multiply(p.modPow(n, m));
        ret = ret.divide(BigInteger.valueOf(2));
        ret = ret.mod(m);
        System.out.println(ret);
    }

}

import java.util.List;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
import java.util.Collection;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Egor Kulikov (egor@egork.net)
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
	private static final long MOD = 1000000007;

	public void solve(int testNumber, InputReader in, OutputWriter out) {
		long yearCount = in.readLong();
		long answer;
		if (yearCount != 0)
			answer = IntegerUtils.power(2, yearCount - 1, MOD) * (IntegerUtils.power(2, yearCount, MOD) + 1) % MOD;
		else
			answer = 1;
		out.printLine(answer);
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public static boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}

	public OutputWriter(Writer writer) {
		this.writer = new PrintWriter(writer);
	}

	public void print(Object...objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(Object...objects) {
		print(objects);
		writer.println();
	}

	public void close() {
		writer.close();
	}

	}

class IntegerUtils {

	public static long power(long base, long exponent, long mod) {
		if (exponent == 0)
			return 1;
		long result = power(base, exponent >> 1, mod);
		result = result * result % mod;
		if ((exponent & 1) != 0)
			result = result * base % mod;
		return result;
	}

	}

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class A118 {
	public static long MOD = 1000*1000*1000+7;
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		long n = Long.parseLong(s.next());
		if(n == 0) {
			System.out.println(1); return;
		}
		Map<Long, Long> m = new HashMap<Long, Long>();
		System.out.println((exp(2,n-1,MOD, m)%MOD*(exp(2,n,MOD,m)+1)%MOD)%MOD);
	}

	public static long exp(long b, long e, long mod, Map<Long, Long> map) {
		if(e == 0) return 1;
		if(e == 1) return b;
		if(map.get(e) != null) return map.get(e)%mod;
		else {
			if(e%2 == 0) {
				map.put(e, (exp(b,e/2,mod,map)%mod)*(exp(b,e/2,mod,map)%mod)%mod);
				return map.get(e);
			}
			else {
				map.put(e, ((exp(b,e/2,mod, map)%mod)*(exp(b,e/2,mod, map)%mod)*b)%mod);
				return map.get(e);
			}
		}
	}
}

import java.util.Scanner;

public class A {
    static int mod = 1000000007;

    public static long[][] expon(long pow) {
        long[][] init = new long[2][2];
        init[0][0] = 3;
        init[0][1] = 1;
        init[1][0] = 1;
        init[1][1] = 3;
        long[][] ident = new long[2][2];
        ident[0][0] = ident[1][1] = 1;
        while (pow > 0) {
            if ((pow & 1) == 1) {
                long[][] tmp = new long[2][2];
                for (int i = 0; i < 2; i++) {
                    for (int j = 0; j < 2; j++) {
                        for (int k = 0; k < 2; k++) {
                            tmp[i][j] = (tmp[i][j] + (init[i][k] * ident[k][j])
                                    % mod)
                                    % mod;
                        }
                    }
                }
                ident = tmp;
            }
            long[][] tmp = new long[2][2];
            for (int i = 0; i < 2; i++) {
                for (int j = 0; j < 2; j++) {
                    for (int k = 0; k < 2; k++) {
                        tmp[i][j] = (tmp[i][j] + (init[i][k] * init[k][j])
                                % mod)
                                % mod;
                    }
                }
            }
            init = tmp;
            pow >>= 1;
        }
        return ident;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long[][] res = expon(n);
        System.out.println(res[0][0]);
    }
}

import java.io.*;
import java.util.StringTokenizer;

public class A {
	BufferedReader in;
	StringTokenizer str;
	PrintWriter out;
	String SK;

	String next() throws IOException {
		while ((str == null) || (!str.hasMoreTokens())) {
			SK = in.readLine();
			if (SK == null)
				return null;
			str = new StringTokenizer(SK);
		}
		return str.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	long mod = (long) (1e+9 + 7);

	long pow(long a, long b) {
		long res = 1;
		long mul = a;
		while (b > 0) {
			if (b % 2 == 1) {
				res = (res * mul) % mod;
			}
			mul = (mul * mul) % mod;
			b /= 2;
		}
		return res;
	}

	void solve() throws IOException {
		long n = nextLong();
		out.println((pow(2, 2 * n - 1) + pow(2, n) - pow(2, n - 1) + 5 * mod)
				% mod);
	}

	void run() throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new A().run();
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Plant {

	static class Scanner{
		BufferedReader br=null;
		StringTokenizer tk=null;
		public Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		public String next() throws IOException{
			while(tk==null || !tk.hasMoreTokens())
				tk=new StringTokenizer(br.readLine());
			return tk.nextToken();
		}
		public int nextInt() throws NumberFormatException, IOException{
			return Integer.valueOf(next());
		}
	}

	static int mod=1000000007;

	static int[][] multiplicar(int[][] a,int[][] b){
		int[][] ret=new int[2][2];
		for(int i=0;i<2;i++){
			for(int j=0;j<2;j++){
				int tmp=0;
				for(int k=0;k<2;k++){
					int t=(int)( ((1L*a[i][k]) * b[k][j])%mod );
					tmp = (tmp + t ) % mod;
				}
				ret[i][j]=tmp;
			}
		}
		return ret;
	}

	static int[][] exponenciacion(int[][] m,long exp){
		if (exp==1)
			return m;
		int[][] tmp=exponenciacion(m,exp/2);
		tmp=multiplicar(tmp,tmp);
		if (exp%2==1)
			tmp=multiplicar(tmp,m);
		return tmp;
	}

	public static void main(String args[]) throws NumberFormatException, IOException{
		Scanner sc=new Scanner();
		long N=Long.valueOf(sc.next());
		if (N==0){
			System.out.println("1");
			return;
		}
		int[][] m={{3,1},{1,3}};
		int[][] matrix=exponenciacion(m,N);
		System.out.println(matrix[0][0]);
	}

}

import java.io.InputStream;
import java.io.OutputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.StringTokenizer;

public class Task {

	public static void main(String args[]){
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		PrintWriter out = new PrintWriter(outputStream);
		InputReader in = new InputReader(inputStream);

		Solver s = new Solver(in,out);
		s.solve();

		out.close();
	}
}

class Solver{
	private InputReader in;
	private PrintWriter out;
	Solver(InputReader in, PrintWriter out){
		this.in = in;
		this.out = out;
	}

	private long b[];
	private static final long mod = 1000000007;

	private long[] ymn(long a[], long b[]){
		long c[] = new long[4];
		c[0]=a[0]*b[0]+a[1]*b[2];
		c[1]=a[0]*b[1]+a[1]*b[3];
		c[2]=a[2]*b[0]+a[3]*b[2];
		c[3]=a[2]*b[1]+a[3]*b[3];
		c[0]=c[0]%mod;
		c[1]=c[1]%mod;
		c[2]=c[2]%mod;
		c[3]=c[3]%mod;
		return c;
	}

	private long[] Binary(long st){
		if (st==1)
			return b;
		if (st%2==0){
			long temp[] = Binary((long)st/2);
			return ymn(temp, temp);
		}
		return ymn(Binary(st-1),b);
	}

	public void solve(){
		long n=in.nextLong();
		if (n==0){
			out.println("1");
			return;
		}
		b = new long[4];
		b[0]=b[3]=3;
		b[1]=b[2]=1;
		b = Binary(n);
		out.println(b[0]);
	}
}

class InputReader{
	private BufferedReader buf;
	private StringTokenizer tok;

	InputReader(InputStream in){
		tok = null;
		buf = new BufferedReader(new InputStreamReader(in));
	}

	public String next(){
		while (tok==null || !tok.hasMoreTokens()){
			try{
				tok = new StringTokenizer(buf.readLine());
			}catch (IOException e){
				throw new RuntimeException(e);
			}
		}
		return tok.nextToken();
	}

	public int nextInt(){
		return Integer.parseInt(next());
	}

	public long nextLong(){
		return Long.parseLong(next());
	}

	public double nextDouble(){
		return Double.parseDouble(next());
	}

	public float nextFloat(){
		return Float.parseFloat(next());
	}
}

import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Main implements Runnable {

    static String filename = "";

    static final long mod = 1000 * 1000 * 1000 + 7;

    long[][] m = new long[][] {
        { 3, 1 },
        { 1, 3 }
    };

    long[][] matrixMul(long[][] m1, long[][] m2) {
        long[][] ans = new long[2][2];
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 2; j++) {
                for (int k = 0; k < 2; k++) {
                    ans[i][j] += m1[i][k] * m2[k][j];
                    ans[i][j] %= mod;
                }
            }
        }
        return ans;
    }

    long[][] matrixPow(long[][] m, long e) {
        long[][] ans = new long[][] { { 1, 0 }, { 0, 1 } };
        while (e > 0) {
            if (e % 2 == 1) {
                ans = matrixMul(ans, m);
            }
            m = matrixMul(m, m);
            e /= 2;
        }
        return ans;
    }

    public void solve() throws Exception {
        long n = sc.nextLong();
        long[][] ansm = matrixPow(m, n);
        out.println(ansm[0][0]);
    }

    BufferedReader in;
    PrintWriter out;
    FastScanner sc;

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 1 << 25).start();
    }

    @Override
    public void run() {
        try {
            init();
            solve();
        } catch (Throwable e) {
            throw new RuntimeException(e);
        } finally {
            out.close();
        }
    }

    void init() throws Exception {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        sc = new FastScanner(in);
    }
}

class FastScanner {

    BufferedReader reader;
    StringTokenizer strTok;

    public FastScanner(BufferedReader reader) {
        this.reader = reader;
    }

    public String nextToken() throws IOException {
        while (strTok == null || !strTok.hasMoreTokens()) {
            strTok = new StringTokenizer(reader.readLine());
        }

        return strTok.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    public BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.Scanner;

public class C {
    static InputStreamReader in = new InputStreamReader(System.in);
    static BufferedReader bf = new BufferedReader(in);
    static StreamTokenizer st = new StreamTokenizer(bf);
    static final long mod = (long)(1e9) + 7 ;
    public static void main(String[] args) throws IOException{
        long n = new Scanner(System.in).nextLong();
        BigInteger two = new BigInteger("2");
        long ans1 = two.modPow(new BigInteger((2*n-1)+""), new BigInteger(mod+"")).longValue();
        long ans2 = two.modPow(new BigInteger((n-1)+""), new BigInteger(mod+"")).longValue();
        System.out.println((ans1+ans2)%mod);

    }
    private static long nextLong() throws IOException{
        st.nextToken();
        return (long) st.nval;
    }

}

import java.util.Arrays;
import java.util.Locale;
import java.util.Scanner;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main{
    public static void main(String[]arg){
        Scanner cin=new Scanner(System.in);
        cin.useLocale(Locale.ENGLISH);
        BigInteger n,r,s;
        BigInteger c=new BigInteger("4");
        BigInteger d=new BigInteger("2");
        BigInteger m=new BigInteger("1000000007");

        while(cin.hasNextBigInteger()){
            n=cin.nextBigInteger();
            if(n.compareTo(BigInteger.ZERO)==0){
                System.out.println(1);
                continue;
            }
            r=d.modPow(n,m).subtract(BigInteger.ONE);
            s=d.modPow(n.subtract(BigInteger.ONE), m);
            r=(r.multiply(s)).mod(m);

            BigInteger x= (c.modPow(n, m).subtract(r)).mod(m) ;
            if(x.signum()<0)x=x.add(m);
            System.out.println(x.mod(m));
        }

    }
}

import java.util.Arrays;
import java.util.Locale;
import java.util.Scanner;
import java.math.BigDecimal;
import java.math.BigInteger;

//POR CULPA DEL LIC. NO PUDE LLEGAR A PARTICIPAR :-(  :\
public class Main{
    public static void main(String[]arg){
        Scanner cin=new Scanner(System.in);
        cin.useLocale(Locale.ENGLISH);
        BigInteger n,r,s;
        BigInteger c=new BigInteger("4");
        BigInteger d=new BigInteger("2");
        BigInteger m=new BigInteger("1000000007");

        while(cin.hasNextBigInteger()){
            n=cin.nextBigInteger();
            if(n.compareTo(BigInteger.ZERO)==0){
                System.out.println(1);
                continue;
            }
            r=d.modPow(n,m).subtract(BigInteger.ONE);
            s=d.modPow(n.subtract(BigInteger.ONE), m);
            r=(r.multiply(s)).mod(m);

            BigInteger x= (c.modPow(n, m).subtract(r)).mod(m) ;
            if(x.signum()<0)x=x.add(m);
            System.out.println(x.mod(m));
        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;

public class A {

    private void solve() throws IOException {
        long n = nextInt();
        BigInteger r = new BigInteger(2 + "");

        r = r.modPow(BigInteger.valueOf(n), BigInteger.valueOf(1000000007));

        BigInteger res = new BigInteger(r + "");
        res = res.multiply(r.add(BigInteger.valueOf(1)));
        res = res.divide(BigInteger.valueOf(2));
        System.out.println(res.mod(BigInteger.valueOf(1000000007)));

    }

    public static void main(String[] args) {
        new A().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            solve();
            reader.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    long nextInt() throws IOException {
        return Long.parseLong(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}

import java.io.*;
import java.util.StringTokenizer;

public class Main {
    static final int mod = (int) (1e9 + 7);

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int Q[][] = new int[][]{{3, 1}, {1, 3}};
        int base[][] = new int[][]{{1}, {0}};
        long n = sc.nextLong();
        int res[][] = matMul(matPow(Q, n), base, 2, 2, 1);
        out.println(res[0][0]);
        out.flush();
        out.close();
    }

    static int[][] matMul(int[][] A, int[][] B, int p, int q, int r) {
        int[][] C = new int[p][r];
        for (int i = 0; i < p; ++i)
            for (int j = 0; j < r; ++j)
                for (int k = 0; k < q; ++k)
                    C[i][j] = (int) ((C[i][j] + 1l * A[i][k] * B[k][j]) % mod);
        return C;
    }

    static int[][] matPow(int[][] base, long p) {
        int n = base.length;
        int[][] ans = new int[n][n];
        for (int i = 0; i < n; i++)
            ans[i][i] = 1;
        while (p != 0) {
            if ((p & 1) == 1)
                ans = matMul(ans, base, n, n, n);
            base = matMul(base, base, n, n, n);
            p >>= 1;
        }

        return ans;
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream system) {
            br = new BufferedReader(new InputStreamReader(system));
        }

        public Scanner(String s) throws FileNotFoundException {

            br = new BufferedReader(new FileReader(new File(s)));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public char nextChar() throws IOException {
            return next().charAt(0);
        }

        public Long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

        public int[] nextIntArray(int n) throws IOException {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) throws IOException {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }

        public Integer[] nextIntegerArray(int n) throws IOException {
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public double[] nextDoubleArray(int n) throws IOException {
            double[] ans = new double[n];
            for (int i = 0; i < n; i++)
                ans[i] = nextDouble();
            return ans;
        }

        public short nextShort() throws IOException {
            return Short.parseShort(next());
        }

    }

}

import java.io.*;
import java.util.*;
import java.lang.Math.*;
public class tri
{
     public static void main(String args[])throws Exception
     {
         Scanner in=new Scanner(System.in);
         PrintWriter pw=new PrintWriter(System.out);
         long n=in.nextLong();
         if(n==0)
         pw.println(1);
         else
         {
         long a=decrypt(2,n-1,1000000007);
         long b=decrypt(2,n,1000000007);
         long ans=((a*(b+1)))%1000000007;
         pw.println(ans);
        }
         pw.flush();
     }
     public static long decrypt(long a,long b,long n)
     {
         long res=1;
         while(b>0)
         {
             if (b % 2==1) { res = (res * a) % n; }

              a = (a * a) % n;
               b /= 2;

            }
          return res;
        }
}

import java.io.*;
import java.util.*;

public class C {
	public static void main(String[] args) {
		try {
			new C().solve();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	void solve() throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		long n = Long.parseLong(in.readLine());
		if (n == 0) {
			System.out.println(1);
			return;
		}
		int MOD = 1000000007;
		long[] memo = new long[100];// memo[i]=2^(2^i)
		memo[0] = 2;
		for (int i = 1; i < 64; i++) {
			memo[i] = memo[i - 1] * memo[i - 1] % MOD;
		}
		long k = 1;
		for (int i = 0; (1l << i) <= n - 1; i++) {
			if (((n - 1) & (1l << i)) != 0) {
				k *= memo[i];
				k %= MOD;
			}
		}
		long res = k * ((k * 2 + 1) % MOD) % MOD;
		System.out.println(res);
	}
}

import java.math.BigInteger;
import java.util.*;

public class Main {
    class PKU1001{
        void run(){
            Scanner sc = new Scanner(System.in);
            BigInteger a = new BigInteger(sc.next());
            BigInteger two = new BigInteger("2");
            BigInteger mod = new BigInteger("1000000007");

            System.out.println(two.modPow(a.subtract(BigInteger.ONE),mod).multiply((two.modPow(a,mod).add(BigInteger.ONE))).mod(mod));
        }
    }
    public static void main(String[] args) {
        new Main().new PKU1001().run();
    }
}

import java.math.BigInteger;
import java.util.Scanner;

public class CF185A {

    public static void main(String[] args) {

//        long start = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();

//        BigInteger four = new BigInteger("4");
//        BigInteger two = new BigInteger("2");
//        BigInteger s = new BigInteger("1000000007");
//
//        BigInteger two_n = two.pow(n);
//        BigInteger four_n = four.pow(n);
//
//
//        BigInteger two_r = two_n.divide(two).mod(s);
//        BigInteger four_r = four_n.divide(two).mod(s);
//
//        System.out.println((two_r.add(four_r)).mod(s));

        if(n == 0){
            System.out.println(1);
        }else{
            long mod = 1000000007;

            long a = quickpow(2, 2 * n - 1, mod);
            long b = quickpow(2, n - 1, mod);

            System.out.println(((a + b)) % mod);
        }

//        System.out.println(System.currentTimeMillis() - start);

    }

    public static long quickpow(long a, long n, long mod){
        if (n == 1) {
            return a;
        }else if(n > 1){
            long base = quickpow(a,n/2, mod);
            if (n % 2 == 1) {
                return base * base * a % mod;
            }else {
                return base * base % mod;
            }
        }else {
            return 1;
        }
    }

}

import java.util.Scanner;

public class C_118C {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		if(n==0){
			System.out.println(1);
			return;
		}
		long [][] a = {{3,1},{1,3}};
		a = pow(a, n);
		System.out.println(a[0][0]);
	}
	public static long [][] pow(long [][] a, long n){
		if(n==1) return a;
		if(n % 2 == 1) {
			 return  multiply(pow(a, n-1),a);
		}else{
			a = pow(a, n/2);
			return multiply(a, a);
		}
	}
	public static long[][] multiply(long[][] a, long[][] b){
		long [][] c = new long[2][2];
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 2; j++) {
				for (int k = 0; k < 2; k++) {
					c[i][j] += (a[i][k]*b[k][j]) % ((int) (1e+9) + 7);
				}
				c[i][j]%=((double) (1e+9) + 7);
			}
		}
		return c;
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Locale;
import java.util.StringTokenizer;

public class A {

	private long pow(long a, long p, long mod) {
		if (p == 0) {
			return 1;
		} else if (p % 2 == 0) {
			return pow((a * a) % mod, p / 2, mod);
		} else {
			return (pow(a, p - 1, mod) * a) % mod;
		}
	}

	private void solve() throws IOException {
		long n = nextLong();
		long mod = (long)(1e9 + 7.0001);

		long p = pow(2, n, mod);
		println(((1 + p) * p / 2) % mod);
	}

	private String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	private int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	private double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private void print(Object o) {
		writer.print(o);
	}

	private void println(Object o) {
		writer.println(o);
	}

	private void printf(String format, Object... o) {
		writer.printf(format, o);
	}

	public static void main(String[] args) {
		long time = System.currentTimeMillis();
		Locale.setDefault(Locale.US);
		new A().run();
		System.err.printf("%.3f\n", 1e-3 * (System.currentTimeMillis() - time));
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	private void run() {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(13);
		}
	}
}

import java.util.Scanner;

public class HaveANiceDay {
    public static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        long a = in.nextLong();
        long z = power(2, a) % 1000000007;
        long sum = (z * (z + 1)) / 2;
        System.out.println(sum % 1000000007);
    }

    public static long power(long a, long b) {
        long re = 1;
        while (b > 0) {
            if ((b & 1) == 1) {
                re = (re * a) % 1000000007;
            }
            b >>= 1;
            a = (a * a) % 1000000007;
        }
        return re;
    }
}

import java.util.*;
import java.io.*;
import java.math.*;
public class code3 {
	InputStream is;
	PrintWriter out;
	long mod=(int)Math.pow(10,9)+7;
	void solve()
	{
		long n=nl();
		if(n==0)
		{
			out.println("1");
			return;
		}
		long tranform[][]=new long[2][2];
		tranform[0][0]=3;
		tranform[0][1]=1;
		tranform[1][0]=1;
		tranform[1][1]=3;
		long matrix[][]=p(tranform,n,mod);
		//debug(matrix);
		out.println(((matrix[0][0])%mod));
	}
	public static long[][] p(long a[][],long p,long mod)
	{
		long ans[][]=new long[a.length][a[0].length];
		for(int i=0;i<a.length;i++)
		{
			for(int j=0;j<a[i].length;j++)
			{
				if(i==j)
					ans[i][j]=1;
			}
		}
		while(p!=0)
		{
			if(p%2==1)
			{
				ans=mul(ans,a,mod);
			}
			p/=2;
			a=mul(a,a,mod);
		}
		return ans;
	}
	public static long[][] mul(long a[][],long b[][],long mod)
	{
		long ans[][]=new long[a.length][b[0].length];
		for(int i=0;i<a.length;i++)
		{
			for(int j=0;j<b.length;j++)
			{
				long temp=0;
				for(int k=0;k<b.length;k++)
				{
					temp+=(a[i][k]*b[k][j])%mod;
					temp%=mod;
				}
				ans[i][j]=temp;
			}
		}
		return ans;
	}
	public static void mergeSort(int[] arr, int l ,int r){
		if((r-l)>=1){
			int mid = (l+r)/2;
			mergeSort(arr,l,mid);
			mergeSort(arr,mid+1,r);
			merge(arr,l,r,mid);
		}
	}
	public static void merge(int arr[], int l, int r, int mid){
		int n1 = (mid-l+1), n2 = (r-mid);
		int left[] = new int[n1];
		int right[] = new int[n2];
		for(int i =0 ;i<n1;i++) left[i] = arr[l+i];
		for(int i =0 ;i<n2;i++) right[i] = arr[mid+1+i];
		int i =0, j =0, k = l;
		while(i<n1 && j<n2){
			if(left[i]>right[j]){
				arr[k++] = right[j++];
			}
			else{
				arr[k++] = left[i++];
			}
		}
		while(i<n1) arr[k++] = left[i++];
		while(j<n2) arr[k++] = right[j++];
	}
	public static void mergeSort(long[] arr, int l ,int r){
		if((r-l)>=1){
			int mid = (l+r)/2;
			mergeSort(arr,l,mid);
			mergeSort(arr,mid+1,r);
			merge(arr,l,r,mid);
		}
	}
	public static void merge(long arr[], int l, int r, int mid){
		int n1 = (mid-l+1), n2 = (r-mid);
		long left[] = new long[n1];
		long right[] = new long[n2];
		for(int i =0 ;i<n1;i++) left[i] = arr[l+i];
		for(int i =0 ;i<n2;i++) right[i] = arr[mid+1+i];
		int i =0, j =0, k = l;
		while(i<n1 && j<n2){
			if(left[i]>right[j]){
				arr[k++] = right[j++];
			}
			else{
				arr[k++] = left[i++];
			}
		}
		while(i<n1) arr[k++] = left[i++];
		while(j<n2) arr[k++] = right[j++];
	}
	 static class Pair implements Comparable<Pair>{

	        int x,y,k,i;

		Pair (int x,int y){
			this.x=x;
			this.y=y;
		}

		public int compareTo(Pair o) {
					if(this.x!=o.x)
						return Long.compare(this.x,o.x);
					else
						return Long.compare(this.y,o.y);
		}

	        public boolean equals(Object o) {
	            if (o instanceof Pair) {
	                Pair p = (Pair)o;
	                return p.x == x && p.y == y && p.k==k;
	            }
	            return false;
	        }

	        @Override
	        public String toString() {
	            return  "("+x + " " + y +" "+k+" "+i+" )";
	        }

	    }

	    public static boolean isPal(String s){
	        for(int i=0, j=s.length()-1;i<=j;i++,j--){
	                if(s.charAt(i)!=s.charAt(j)) return false;
	        }
	        return true;
	    }
	    public static String rev(String s){
			StringBuilder sb=new StringBuilder(s);
			sb.reverse();
			return sb.toString();
	    }

	    public static long gcd(long x,long y){
		if(x%y==0)
			return y;
		else
			return gcd(y,x%y);
	    }

	    public static int gcd(int x,int y){
		if(x%y==0)
			return y;
		else
			return gcd(y,x%y);
	    }

	    public static long gcdExtended(long a,long b,long[] x){

	        if(a==0){
	            x[0]=0;
	            x[1]=1;
	            return b;
	        }
	        long[] y=new long[2];
	        long gcd=gcdExtended(b%a, a, y);

	        x[0]=y[1]-(b/a)*y[0];
	        x[1]=y[0];

	        return gcd;
	    }

	    public static int abs(int a,int b){
		return (int)Math.abs(a-b);
	    }

	    public static long abs(long a,long b){
		return (long)Math.abs(a-b);
	    }

	    public static int max(int a,int b){
		if(a>b)
			return a;
		else
			return b;
	    }

	    public static int min(int a,int b){
		if(a>b)
			return b;
		else
			return a;
	    }

	    public static long max(long a,long b){
		if(a>b)
			return a;
		else
			return b;
	    }

	    public static long min(long a,long b){
		if(a>b)
			return b;
		else
			return a;
	    }

	    public static long pow(long n,long p,long m){
		 long  result = 1;
		  if(p==0)
		    return 1;
		if (p==1)
		    return n;
		while(p!=0)
		{
		    if(p%2==1)
		        result *= n;
		    if(result>=m)
		    result%=m;
		    p >>=1;
		    n*=n;
		    if(n>=m)
		    n%=m;
		}
		return result;
	    }

	    public static long pow(long n,long p){
		long  result = 1;
		  if(p==0)
		    return 1;
		if (p==1)
		    return n;
		while(p!=0)
		{
		    if(p%2==1)
		        result *= n;
		    p >>=1;
		    n*=n;
		}
		return result;
	    }
	    public static void debug(Object... o) {
			System.out.println(Arrays.deepToString(o));
		}
	    void run() throws Exception {
			is = System.in;
			out = new PrintWriter(System.out);
			solve();
			out.flush();
		}

		public static void main(String[] args) throws Exception {
			new Thread(null, new Runnable() {
				public void run() {
					try {
						new code3().run();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}, "1", 1 << 26).start();
		}

	    private byte[] inbuf = new byte[1024];
		public int lenbuf = 0, ptrbuf = 0;

		private int readByte() {
			if (lenbuf == -1)
				throw new InputMismatchException();
			if (ptrbuf >= lenbuf) {
				ptrbuf = 0;
				try {
					lenbuf = is.read(inbuf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return -1;
			}
			return inbuf[ptrbuf++];
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private int skip() {
			int b;
			while ((b = readByte()) != -1 && isSpaceChar(b))
				;
			return b;
		}

		private double nd() {
			return Double.parseDouble(ns());
		}

		private char nc() {
			return (char) skip();
		}

		private String ns() {
			int b = skip();
			StringBuilder sb = new StringBuilder();
			while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		private char[] ns(int n) {
			char[] buf = new char[n];
			int b = skip(), p = 0;
			while (p < n && !(isSpaceChar(b))) {
				buf[p++] = (char) b;
				b = readByte();
			}
			return n == p ? buf : Arrays.copyOf(buf, p);
		}

		private char[][] nm(int n, int m) {
			char[][] map = new char[n][];
			for (int i = 0; i < n; i++)
				map[i] = ns(m);
			return map;
		}

		private int[] na(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = ni();
			return a;
		}

		private int ni() {
			int num = 0, b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

		private long nl() {
			long num = 0;
			int b;
			boolean minus = false;
			while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
				;
			if (b == '-') {
				minus = true;
				b = readByte();
			}

			while (true) {
				if (b >= '0' && b <= '9') {
					num = num * 10 + (b - '0');
				} else {
					return minus ? -num : num;
				}
				b = readByte();
			}
		}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Plant {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader in  = new BufferedReader(new InputStreamReader(System.in));
		long n = Long.parseLong(in.readLine());
		long y = findPower(2, n);
		long mod = 1000000007;
		System.out.println(((y*(y+1))/2)%mod);

	}

	public static long findPower(long base, long exp){
		long mod = 1000000007;
		if(base == 0){
			return 0;
		}
		if(exp == 0){
			return 1;
		} else if(exp==1){
			return base;
		} else {
			long out = 1;
			while(exp > 0){
				if(exp % 2 != 0){
					out = out*base;
					out = out % mod;
				}
				base = base*base;
				base = base % mod;
				exp = exp /2;
			}
			return out;
		}
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Omar Yasser
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        static int[][] zero(int n, int m) {
            return new int[n][m];
        }

        static int[][] identity(int n) { // Always square matrix
            int[][] x = zero(n, n);
            for (int i = 0; i < x.length; i++)
                x[i][i]++;
            return x;
        }

        static int[][] multiply(int[][] a, int[][] b) {
            int[][] ret = zero(a.length, b[0].length);
            // Optimizations here not to enter the last loop of a[i][k] = 0
            // Also we can swtich last two loops if b[k][j] has more zeros

            //for MOD optimization we use the following
            int mod = (int) 1e9 + 7;
            for (int i = 0; i < a.length; ++i) {
                for (int k = 0; k < a[0].length; ++k) {
                    for (int j = 0; j < b[0].length; ++j) {
                        ret[i][j] += (((long) a[i][k] * b[k][j]) % mod);
                        if (ret[i][j] >= mod) ret[i][j] -= mod;
                    }
                }

            }
            return ret;
        }

        static int[][] matPow(int[][] a, long k) { //N^3 LOG
            if (k == 0) return identity(a.length);
            if (k % 2 == 1) {
                return multiply(a, matPow(a, k - 1));
            }
            return matPow(multiply(a, a), k >> 1);
        }

        public void solve(int testNumber, Scanner sc, PrintWriter out) {
            long n = sc.nextLong();
            int res[][] = multiply(new int[][]{{1, 0}, {1, 1}}, matPow(new int[][]{{3, 1}, {1, 3}}, n));
            out.println(res[0][0]);
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }

        public String next() {
            while (st == null || !st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author DOAN Minh Quy
 * @e-mail mquy.doan@gmail.com
 */
public class C186 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        try {
            long n = Long.parseLong(buffer.readLine().toString());
            MatrixC186 solver = new MatrixC186();
            System.out.println(solver.run(n));
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
class MatrixC186{
    long matrix[][];
    final long MOD = 1000000007;
    public MatrixC186(){
        matrix = new long[][]{{3,1},{1,3}};
    }
    long[][] powerMod(long n){
        long i = 1;
        long rep[][] = new long[][]{{1,0},{0,1}};
        long pow[][] = multiply(rep,matrix);
        while(i<=n){
            if ( (n&i) >= 1 ){
                rep = multiply(rep,pow);
            }
            i *= 2;
            pow = multiply(pow,pow);
        }
        return rep;
    }
    long[][] multiply(long[][] a,long[][] b){
        long[][] rep = new long[2][2];
        for(int row = 0 ; row < 2 ; ++row){
            for(int col = 0 ; col < 2 ; ++col){
                rep[row][col] = 0;
                for(int mid = 0 ; mid < 2 ; ++mid){
                    rep[row][col] = (rep[row][col]+a[row][mid] * b[mid][col]) % MOD;
                }
            }
        }
        return rep;
    }
    public long run(long n){
        long rep[][] = powerMod(n);
        return rep[0][0] % MOD;
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class round118A {
    static long mod = (long)1e9 + 7;

    public static long[][] modPow(long[][] x, long pow) {
        if (pow == 0)
            return new long[][] { { 1, 0, 0}, { 0, 1, 0 }, {0, 0, 1}};
        long[][] y = modPow(x, pow >> 1);
        y = mulMod(y, y);
        if ((pow & 1) != 0)
            y = mulMod(y, x);
        return y;
    }

    public static long[][] mulMod(long[][] x, long[][] y) {
        long[][] z = new long[3][3];
        for (int i = 0; i < 3; i++)
            for (int j = 0; j < 3; j++)
                for (int k = 0; k < 3; k++)
                    z[i][j] = (z[i][j] + (x[i][k] * y[k][j]) % mod) % mod;
        return z;
    }
    public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long n = Long.parseLong(br.readLine());
        long [][] matrix = new long [][] {{3, 3, 1}, {0, 3, 1}, {1, 0, 0}};
        long [][] exp_matrix = modPow(matrix, n);
        long [] vector = new long [] {1, 0, 0};
        long ans = 0;
        for(int i = 0 ; i < 3 ; ++i){
            ans += exp_matrix[0][i] * vector[i];
            ans %= mod;
        }
        System.out.println(ans);

    }
}

import java.util.*;
import java.math.*;
import java.math.*;
import java.io.*;
import java.*;
import java.lang.*;
public class ffff
{
	static int N=(int)1e5+10,MOD=(int) ((1e9)+7);
	static long a;
	static Scanner in=new Scanner(System.in);
	static long binPow(long base,long pwr)
	{
		if(pwr==0)
			return 1;
		long val=binPow(base, pwr/2);
		if(pwr%2!=0)
			return ((((val * val) % MOD) * base) % MOD);
		return (val * val) % MOD;

	}
	public static void main(String[] arge)
	{

		a=in.nextLong();
		long x=binPow(2,a);
		System.out.println(((x*(x+1))/2)%MOD);

	}

}

import java.util.Scanner;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author mthai
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CF_185A solver = new CF_185A();
        solver.solve(1, in, out);
        out.close();
    }
}

class CF_185A {
    int mod = 1000000007;
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        long n = in.nextLong();

        long x = modPow(2l, n);
        long ans = x * (x + 1) / 2;
        ans %= mod;
        out.println(ans);
    }

    long modPow(long base, long exp) {
        long rs = 1;
        while(exp > 0) {
            if((exp & 1) == 1) {
                rs = (rs * (base % mod)) % mod;
            }
            exp >>= 1;
            base = ((base % mod)* (base % mod)) % mod;
        }
        return rs;
    }
}

//package codeforcespracice;
import java.io.*;
import java.util.*;
public class plant {
    static int mod=(int)1e9+7;
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong();
        long ans1=pow(4,n-1);
        long ans2=pow(2,n-1);
        if(n==0)
        {
            System.out.println(1);
            System.exit(0);
        }
        long ans=(2*ans1+ans2)%mod;
        System.out.println(ans);

    }
    public static long pow(int x,long y)
    {
        if(y==0)
        {
            return 1;
        }
        if(y%2==0)
        {
            long temp=pow(x,y/2);
            return temp*temp%mod;
        }
        else
        {
            long temp=pow(x,y/2);
            return (((temp*temp)%mod)*x)%mod;
        }
    }

}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in Actual solution is at the top
 *
 * @author MaxHeap
 */
public class Main {

  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    Plant solver = new Plant();
    solver.solve(1, in, out);
    out.close();
  }

  static class Plant {

    final long MOD = (long) (1e9 + 7);

    public void solve(int testNumber, InputReader in, PrintWriter out) {
      long n = in.nextLong();
      long[][] mat = {
          {3, 1},
          {1, 3}
      };
      long[][] expo = Matrix.matrixPow(mat, n, MOD);
      out.println(expo[0][0]);
    }

  }

  static class Matrix {

    public static long[][] matrixMul(long[][] a, long[][] b, long mod) {
      int n = a.length;
      int m = a[0].length;
      int k = b[0].length;
      long[][] res = new long[n][k];
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
          for (int p = 0; p < m; p++) {
            res[i][j] = (res[i][j] + a[i][p] * b[p][j] % mod + mod) % mod;
          }
        }
      }
      return res;
    }

    public static long[][] matrixPow(long[][] a, long p, long mod) {
      if (p == 0) {
        return matrixUnitLong(a.length);
      } else if (p % 2 == 0) {
        return matrixPow(matrixMul(a, a, mod), p / 2, mod);
      } else {
        return matrixMul(a, matrixPow(a, p - 1, mod), mod);
      }
    }

    public static long[][] matrixUnitLong(int n) {
      long[][] res = new long[n][n];
      for (int i = 0; i < n; ++i) {
        res[i][i] = 1;
      }
      return res;
    }

  }

  static class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1 << 13];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (this.numChars == -1) {
        throw new UnknownError();
      } else {
        if (this.curChar >= this.numChars) {
          this.curChar = 0;

          try {
            this.numChars = this.stream.read(this.buf);
          } catch (IOException ex) {
            throw new InputMismatchException();
          }

          if (this.numChars <= 0) {
            return -1;
          }
        }

        return this.buf[this.curChar++];
      }
    }

    public long nextLong() {
      int c;
      for (c = this.read(); isSpaceChar(c); c = this.read()) {
      }

      byte sgn = 1;
      if (c == 45) {
        sgn = -1;
        c = this.read();
      }

      long res = 0;

      while (c >= 48 && c <= 57) {
        res *= 10L;
        res += c - 48;
        c = this.read();
        if (isSpaceChar(c)) {
          return res * sgn;
        }
      }
      throw new InputMismatchException();
    }

    public static boolean isSpaceChar(int c) {
      return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
    }

  }
}

import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Tests{
	static Scanner in = new Scanner (System.in);
	//static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

	static long MOD = 1000000007;

	static PrintWriter out = new PrintWriter (System.out);

	public static void main (String []args){
		long n = in.nextLong();
		if(n == 0){
			out.println(1);
			out.close();
			System.exit(0);
		}

		long mat [][]={{3,1},{1,3}};
		long ans[][] = pow(mat,n);
		out.println(ans[0][0]%MOD);

	   out.flush();
		out.close();

	}
    static long[][] pow(long a[][], long n) {
        if (n == 1) {
            return a;
        } else if (n % 2 == 0) {
            long t[][] = pow(a, n / 2);
            return mul(t, t);
        } else {
            long t[][] = pow(a, n - 1);
            return mul(a, t);
        }
    }

    static long[][] mul (long[][] a, long[][] b) {
        long[][] c = new long[a.length][a.length];
        for (int i = 0; i < a.length; ++i) {
            for (int j = 0; j < a.length; ++j) {
                for (int k = 0; k < a.length; ++k) {
                    c[i][j] = (c[i][j] + a[i][k] * b[k][j]) % MOD;
                }
            }
        }
        return c;
    }

}

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.*;

/*
 * Daniel Otero Baguer
 * CodeForces #95
 * Problem: C
 */

public class C
{
	BufferedReader in;
	PrintStream out;
	StringTokenizer tok;
	public C() throws NumberFormatException, IOException
	{
		in = new BufferedReader(new InputStreamReader(System.in));
		//in = new BufferedReader(new FileReader("in.txt"));
		out = System.out;
		run();
	}
	long modPow(long n)
	{
		if(n==0) return 1;
		long k = modPow(n/2);
		if(n%2==1) return (k*k*2)%1000000007;
		else return (k*k)%1000000007;
	}
	void run() throws NumberFormatException, IOException
	{
		long n = nextLong();
		long p = modPow(n);
		out.println((p*(p+1)/2)%1000000007);
	}
	public static void main(String[] args) throws NumberFormatException, IOException
	{
		new C();
	}
	String nextToken() throws IOException
	{
		if(tok ==null || !tok.hasMoreTokens()) tok = new StringTokenizer(in.readLine());
		return tok.nextToken();
	}
	int nextInt() throws NumberFormatException, IOException
	{
		return Integer.parseInt(nextToken());
	}
	long nextLong() throws NumberFormatException, IOException
	{
		return Long.parseLong(nextToken());
	}
	double nextDouble() throws NumberFormatException, IOException
	{
		return Double.parseDouble(nextToken());
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class C implements Runnable {

	final long MOD = 1000000000 + 7;

	private void Solution() throws IOException {
		long n = nextLong();
		long t = binpow(2, n);
		long ans = ((t + 1) * t / 2) % MOD;
		println(ans);
	}

	long binpow(long a, long n) {
		long res = 1;
		while (n != 0) {
			if (n % 2 == 1) {
				res *= a;
				res %= MOD;
			}
			a *= a;
			a %= MOD;
			n >>= 1;
		}
		return res;
	}

	public static void main(String[] args) {
		new C().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tokenizer;

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			Solution();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(0);
		}
	}

	void print(Object... o) {
		for (int i = 0; i < o.length; i++) {
			if (i != 0)
				out.print(" ");
			out.print(o[i]);
		}
	}

	void println(Object... o) {
		for (int i = 0; i < o.length; i++) {
			if (i != 0)
				print(" ");
			print(o[i]);
		}
		print("\n");
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(next());
	}

	double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(next());
	}

	String nextLine() throws IOException {
		return in.readLine();
	}

	String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(nextLine());
		return tokenizer.nextToken();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class C186_Plant {
    private static final long MOD = 1000000007;
    private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static StringTokenizer st;

    public static void main(String[] args) {
        PrintWriter pw = new PrintWriter(System.out);
        long n = nextLong();
        long x = modPow(2, n - 1, MOD);
        pw.println(n == 0 ? 1 : x * (2 * x + 1) % MOD);
        pw.close();
    }

    private static long modPow(long x, long y, long m) {
        int res = 1;
        x = x % m;
        while (y > 0) {
            if ((y & 1) == 1)
                res = (int) ((res * x) % m);
            y = y >> 1;
            x = (x * x) % m;
        }
        return res;
    }

    private static String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    private static String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }

    private static int nextInt() {
        return Integer.parseInt(next());
    }

    private static long nextLong() {
        return Long.parseLong(next());
    }

    private static double nextDouble() {
        return Double.parseDouble(next());
    }
}

import java.math.BigInteger;
import java.util.Scanner;

public class Plant186C {
	public static final int DIVISOR = 1000000007;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long y = in.nextLong();
		if (y == 0)
			report(1);
		long value = powerOfTwo(2 * y - 1) + powerOfTwo(y - 1);
		report(value % DIVISOR);
	}

	private static long powerOfTwo(final long pow) {
		long t = pow;
		long step = 2;
		long res = 1;
		while (t > 0) {
			if ((t & 1) == 1) {
				res *= step;
			}
			step *= step;
			t >>>= 1;
			if (res > DIVISOR)
				res %= DIVISOR;
			if (step > DIVISOR)
				step %= DIVISOR;
		}
		return res;
	}

	private static void report(long i) {
		System.out.println(i);
		System.exit(0);
	}
}

//import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Scanner;

public class B {
	static BigInteger nb = new BigInteger("1000000007");

	public static String rightToLeftBinary(String a, String b) {
		BigInteger ab = new BigInteger(a);
		BigInteger bb = new BigInteger(b);

		BigInteger t = BigInteger.valueOf(Integer.MAX_VALUE);
		int i = 0;
		while (bb.compareTo(t) == 1) {
			bb = bb.divide(BigInteger.valueOf(Integer.MAX_VALUE));
			i++;
		}
		int l = bb.intValue();
		t = BigInteger.valueOf(1);
		for (int j = 0; j <= i; j++)
			while (l > 0) {
				if ((l & 1) == 1)
					t = t.multiply(ab).mod(nb);
				l = l >> 1;
				ab = ab.multiply(ab).mod(nb);
			}
		return t.toString();
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		BigInteger h = new BigInteger("2").modPow(new BigInteger(x), nb);
		// String t = rightToLeftBinary("2", x);
		// BigInteger b = new BigInteger(t).mod(nb);
		BigInteger c = h.add(BigInteger.valueOf(1));
		c = c.multiply(h);
		c = c.divide(BigInteger.valueOf(2));

		System.out.println(c.mod(nb));
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author cunbidun
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        Task186C solver = new Task186C();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task186C {
        private InputReader in;
        private OutputWriter out;

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            this.in = in;
            this.out = out;
            int[][] b = new int[3][3];
            b[1][1] = 3;
            b[1][2] = 1;
            b[2][1] = 1;
            b[2][2] = 3;
            long n = in.nextLong();
            b = MatrixOp.powMatrix(b, n, (int) (1e9 + 7));
            int[][] ans = new int[2][3];
            ans[1][1] = 1;
            ans[1][2] = 0;
            ans = MatrixOp.mulMatrixMatrix(ans, b);
            out.println(ans[1][1]);
        }

    }

    static class InputReader extends InputStream {
        private InputStream stream;
        private byte[] buf = new byte[1 << 16];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }

    static class Op {
        public static int addMod(int x, int y, int MOD) {
            return ((x + y) >= MOD ? x + y - MOD : x + y);
        }

        public static int mulMod(int x, int y, int MOD) {
            return (int) (((long) x * y) % MOD);
        }

    }

    static class OutputWriter {
        private final PrintWriter out;

        public OutputWriter(OutputStream outputStream) {
            out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.out = new PrintWriter(writer);
        }

        public void close() {
            out.close();
        }

        public void println(int i) {
            out.println(i);
        }

    }

    static class MatrixOp {
        public static int[][] mulMatrixMatrix(int[][] x, int[][] y, int MOD) {
            int xR = x.length - 1;
            int xC = x[1].length - 1;
            int yC = y[1].length - 1;
            int[][] ans = new int[xR + 1][yC + 1];
            for (int i = 1; i <= xR; i++) {
                for (int j = 1; j <= yC; j++) {
                    for (int l = 1; l <= xC; l++) {
                        ans[i][j] = Op.addMod(ans[i][j], Op.mulMod(x[i][l], y[l][j], MOD), MOD);
                    }
                }
            }
            return ans;
        }

        public static int[][] powMatrix(int[][] x, long n, int MOD) {
            if (n == 0) {
                int len = x.length - 1;
                int[][] I = new int[len + 1][len + 1];
                for (int i = 1; i <= len; i++) {
                    I[i][i] = 1;
                }
                return I;
            }
            if (n == 1) return x;
            int[][] t = powMatrix(x, n / 2, MOD);
            return mulMatrixMatrix(mulMatrixMatrix(t, t, MOD), powMatrix(x, n % 2, MOD), MOD);
        }

        public static int[][] mulMatrixMatrix(int[][] x, int[][] y) {
            int xR = x.length - 1;
            int xC = x[1].length - 1;
            int yC = y[1].length - 1;
            int[][] ans = new int[xR + 1][yC + 1];
            for (int i = 1; i <= xR; i++) {
                for (int j = 1; j <= yC; j++) {
                    for (int l = 1; l <= xC; l++) {
                        ans[i][j] += (x[i][l] * y[l][j]);
                    }
                }
            }
            return ans;
        }

    }
}

import java.math.BigInteger;
import java.util.Scanner;
public class cf185a {
  static long mod = 1000000007;
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    long n = in.nextLong();
    long ans = (pow(4,n)+pow(2,n))%mod;
    long inv = BigInteger.valueOf(2).modInverse(BigInteger.valueOf(mod)).longValue();
    ans = (ans*inv)%mod;
    System.out.println(ans);
  }
  static long pow(long x, long p) {
    if(p == 0) return 1;
    long tmp = pow(x,p>>1);
    tmp = (tmp*tmp)%mod;
    if((p&1)==1) tmp = (tmp*x)%mod;
    return tmp;
  }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        static long MODL = 1_000_000_007L;

        public void solve(int testNumber, Scanner in, PrintWriter out) {

            long n = in.nextLong();
        /*
        children / 4 * 3/4*3

        up = 3x+y
        down = x+3y

        up + down = 4^i
        3x + y + x + 3y = 4^i

        total /4 *3 = up
        total /4 /4 = up

        total/16*9 + total/16 = total * 10/16

        4^(n/k)*k

        4^10 = 16^5 = 16^(2*2)*16 = 256^2*16
        */

            //x = (4^i+2^i)/2 => (2^i*2+2^i)/2 = a(a+1)/2

            long a = pow(2, n);

//        System.out.printf("a=%d\n", a);

            long x = a * (a + 1) / 2 % MODL;

            out.print(x);
        }

        static long pow(long base, long p) {

            long r = 1;
            if (p == 0) return 1;

            while (p > 1) {
                if (p % 2 != 0) {
                    r = (r * base) % MODL;
                }

                base = (base * base) % MODL;
                p /= 2;
//            System.out.printf("b=%d,r=%d,p=%d\n", base, r, p);
            }

            return (base * r) % MODL;
        }

    }
}

import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner cin=new Scanner(System.in);
		BigInteger a,b,c,tmp,MOD;
		long n;
		n=cin.nextLong();
		a=BigInteger.valueOf(2);
		c=a;
		b=BigInteger.valueOf(1);
		MOD=BigInteger.valueOf(1000000007);
		while (n>0)
		{
			if (n%2==1) b=b.multiply(c);
			c=c.multiply(c);
			b=b.mod(MOD);
			c=c.mod(MOD);
			n>>=1;
		}
		tmp=b.add(BigInteger.valueOf(1));
		tmp=tmp.multiply(b);
		tmp=tmp.divide(a);
		tmp=tmp.mod(MOD);
		System.out.println(tmp);
	}

}

import java.io.*;
import java.util.*;

public class Main {
    public static void main (String[] args) {new Main();}

    Main () {
        FastScanner fs = new FastScanner();
        Scanner s = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        long n = fs.nextLong();
        long m = (long)1e9 + 7;
        long m1 = power(2, n, m);

        out.println(summation(m1, m) % m);

        out.close();
    }

    static final Long INVERSE2 = 500000004L;

    long power (long x, long y, long m) {
    	long res = 1;
    	x %= m;
    	while(y > 0) {
    		if(y % 2 == 1) {
    			res = (res * x) % m;
    		}
    		y >>= 1L;
    		x = (x * x) % m;
    	}
    	return res;
    }

    long summation (long x, long m) {
    	long res = ((x%m) * ((x+1)%m)) % m;
    	res = ((res%m) * (INVERSE2%m))%m;
    	return res;
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                //                br = new BufferedReader(new FileReader("testdata.out"));
                st = new StringTokenizer("");
            } catch (Exception e){e.printStackTrace();}
        }
        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }
        public int nextInt() {return Integer.parseInt(next());}
        public long nextLong() {return Long.parseLong(next());}
        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            try {line = br.readLine();}
            catch (Exception e) {e.printStackTrace();}
            return line;
        }
        public Integer[] nextIntegerArray(int n) {
            Integer[] a = new Integer[n];
            for(int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }
        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for(int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }
        public char[] nextCharArray() {return nextLine().toCharArray();}
    }

}

import java.io.*;
public class plant{
public static long mod = 1000000007;
public static void main(String args[]) throws IOException{
BufferedReader lector = new BufferedReader(new InputStreamReader(System.in));
long p = Long.parseLong(lector.readLine());
if(p==0){
System.out.println("1");
return;
}
long pp = exp(2,p-1);
long res = (((pp)%mod)*((2*pp+1)%mod))%mod;
System.out.println(res);
}
public static long exp(long a,long b){
if(b==0)return 1;
if(b==1)return a;
long t = 0;
if((b&1)==0)t = exp(a,b/2);
return ((b&1)==0)?(t*t)%mod:(exp(a,b-1)*a)%mod;
}
}

import java.util.Scanner;

public class Plant {
	static int MOD = 1000000007;

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long n = scan.nextLong();

		if (n != 0) {
		long x = po(2,n-1);
		System.out.println((long)(x * (2 * x + 1)) % MOD);
		} else
			System.out.println(1);
	}

	static long po(long b, long p) {
	    p %= (MOD-1);
	    if (p == 0)
	    	return 1;

	    return po(b * b % MOD, p / 2) * ((p & 1) == 1 ? b : 1 ) % MOD;
	}

}

import java.math.BigInteger;
import java.util.Scanner;

public class Round118_C {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        BigInteger two = new BigInteger("2");
        BigInteger n = new BigInteger(in.next());
        long z = two.modPow(n, new BigInteger("1000000007")).longValue();
        System.out.println(((z * (z + 1)) / 2) % 1000000007);

    }

}

import java.util.*;
import java.io.*;
import java.math.*;

public class C {
    public static StreamTokenizer in = new StreamTokenizer(System.in);
    public static boolean bg = true;
    public static MOD m1 = new MOD(1000000007);
    public static HashMap<Long, long[]> map1 = new HashMap();
    static {
        map1.put(0l, new long[]{1,0} );
        map1.put(1l, new long[]{3,1} );
    }
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        long n1 = Long.parseLong(scan.next());
        if (n1 == 0){
            pn(1);
            ex();
        }
        long k1 = m1.pow(2, n1-1);
        long k2 = m1.pow(2, n1);
        k2 = m1.a(1, k2);
        long fin = m1.t(k1, k2);
        pn(fin);
    }
    public static long[] ans (long k1){
        if (map1.containsKey(k1)){
            return map1.get(k1);
        }
        long[] t1 = null;
        long[] fin = new long[2];
        if (k1%2 == 0){
            t1 = ans(k1/2l);
            fin[0] = m1.a(m1.t(t1[0], t1[0]), m1.t(t1[1], t1[1]) );
            fin[1] = m1.t(2l, m1.t(t1[0], t1[1]) );
        }
        else {
            t1 = ans(k1-1l);
            fin[0] = m1.a(m1.t(t1[0], 3), m1.t(t1[1], 1) );
            fin[1] = m1.a(m1.t(t1[0], 1), m1.t(t1[1], 3) );
        }
        //pn(k1+" "+Arrays.toString(t1)+" "+Arrays.toString(fin));
        map1.put(k1, fin);
        return fin;

    }

    public static class MOD {
        public long mod = -1;
        public MOD(long k1){
            mod = k1;
        }
        public long mod(long n1){
            long k1 = n1%mod;
            if (k1<0) k1+=mod;
            return k1;
        }
        public long a(long n1, long n2){
            n1 = mod(n1);
            n2 = mod(n2);
            long k1 = (n1+n2)%mod;
            if (k1<0) k1+= mod;
            return k1;
        }
        public long s(long n1, long n2){
            long k1 = (n1-n2)%mod;
            if (k1<0) k1+= mod;
            return k1;
        }
        public long t(long n1, long n2){
            n1 = mod(n1);
            n2 = mod(n2);
            long k1 = (n1*n2)%mod;
            if (k1<0) k1+=mod;
            return k1;
        }
        public long d(long n1, long n2){
            return (t(n1,xgcd(mod,n2)))%mod;
        }
        public static long xgcd(long n1, long n2){
            long k1 = n1;
            long k2 = n2;
            long[] l1 = {1,0};
            long[] l2 = {0,1};
            for (;;){
                long f1  = k1/k2;
                long f2 = k1%k2;
                if (f2==0) break;

                long[] l3 = {0,0};
                l3[0] = l1[0]- f1*l2[0];
                l3[1] = l1[1]- f1*l2[1];
                l1 = l2;
                l2 = l3;

                k1 = k2;
                k2 = f2;
            }
            long fin = l2[1]%n1;
            if (fin<0){
                fin+=n1;
            }
            return fin;
        }
        public long pow(long n1, long pow){
            if (pow==0) return 1;
            else if (pow==1) return t(1l,n1);
            else if (pow%2==0){
                long half = pow(n1,pow/2);
                return t(half,half);
            }
            else {
                long half = pow(n1,pow/2);
                return t(half,t(half,n1));
            }
        }
    }

    public static int ni() throws Exception {
        in.nextToken();
        return (int) in.nval;
    }

    public static long nl() throws Exception {
        in.nextToken();
        return (long) in.nval;
    }

    public static double nd() throws Exception {
        in.nextToken();
        return in.nval;
    }

    public static String ns() throws Exception {
        in.nextToken();
        return in.sval;
    }

    public static int[] intl(int n1) throws Exception {
        int[] fin = new int[n1];
        for (int i = 0; i < n1; i++) {
            fin[i] = ni();
        }
        return fin;
    }

    public static long[] longl(int n1) throws Exception {
        long[] fin = new long[n1];
        for (int i = 0; i < n1; i++) {
            fin[i] = nl();
        }
        return fin;
    }

    public static double[] doublel(int n1) throws Exception {
        double[] fin = new double[n1];
        for (int i = 0; i < n1; i++) {
            fin[i] = nd();
        }
        return fin;
    }

    public static void pn(Object o1) {
        System.out.println(o1);
    }

    public static void p(Object o1) {
        System.out.print(o1);
    }

    public static void ex() {
        System.exit(0);
    }
}

import java.util.*;
import java.io.*;
public class a {
  static long mod = 1000000007;
public static void main(String[] args) throws IOException
{
  input.init(System.in);
  PrintWriter out = new PrintWriter(new PrintStream(System.out));
  //input.init(new FileInputStream(new File("input.txt")));
  //PrintWriter out = new PrintWriter(new File("output.txt"));
  long n = input.nextLong();
  out.println(n==0?1:(pow(2,n-1)*(1+pow(2,n)))%mod);

  out.close();
}
static long pow(long a, long p)
{
  if(p==0) return 1;
  if((p&1) == 0)
  {
    long sqrt = pow(a, p/2);
    return (sqrt*sqrt)%mod;
  }
  else
    return (a*pow(a,p-1))%mod;
}
static class input {
  static BufferedReader reader;
  static StringTokenizer tokenizer;

  /** call this method to initialize reader for InputStream */
  static void init(InputStream input) {
      reader = new BufferedReader(
                   new InputStreamReader(input) );
      tokenizer = new StringTokenizer("");
  }

  /** get next word */
  static String next() throws IOException {
      while ( ! tokenizer.hasMoreTokens() ) {
          //TODO add check for eof if necessary
          tokenizer = new StringTokenizer(
                 reader.readLine() );
      }
      return tokenizer.nextToken();
  }

  static int nextInt() throws IOException {
      return Integer.parseInt( next() );
  }
  static long nextLong() throws IOException {
    return Long.parseLong( next() );
}

  static double nextDouble() throws IOException {
      return Double.parseDouble( next() );
  }
  static String nextLine() throws IOException {
    return reader.readLine();
  }
}
}

import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class C118C{
    static BufferedReader br;
    public static void main(String args[])throws Exception{
        br=new BufferedReader(new InputStreamReader(System.in));
        long n=toLong();
        if(n==0){
            System.out.println("1");
            return;
        }
        long k=1;
        long count=0;

        BigInteger mod = new BigInteger("1000000007");
        BigInteger bi = new BigInteger("2");
        BigInteger bp = new BigInteger(String.valueOf(n));

        BigInteger f=bi.modPow(bp, mod);
        BigInteger s=(f.add(BigInteger.ONE)).mod(mod);
        //System.out.println(f.toString()+" "+s.toString());
        f=(f.multiply(s)).divide(new BigInteger("2"));
        f=f.mod(mod);
        System.out.println(f.toString());

    }

    /****************************************************************/
    public static int[] toIntArray()throws Exception{
       String str[]=br.readLine().split(" ");
       int k[]=new int[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Integer.parseInt(str[i]);
       }
       return k;
    }
    public static int toInt()throws Exception{
       return Integer.parseInt(br.readLine());
    }
    public static long[] toLongArray()throws Exception{
       String str[]=br.readLine().split(" ");
       long k[]=new long[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Long.parseLong(str[i]);
       }
       return k;
    }
    public static long toLong()throws Exception{
       return Long.parseLong(br.readLine());
    }
    public static double[] toDoubleArray()throws Exception{
       String str[]=br.readLine().split(" ");
       double k[]=new double[str.length];
       for(int i=0;i<str.length;i++){
            k[i]=Double.parseDouble(str[i]);
       }
       return k;
    }
    public static double toDouble()throws Exception{
       return Double.parseDouble(br.readLine());
    }
    public static String toStr()throws Exception{
       return br.readLine();
    }
    public static String[] toStrArray()throws Exception{
       String str[]=br.readLine().split(" ");
       return str;
    }
    /****************************************************************/

}

import java.util.*;
public class susbus{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();;
      long k = (long) (Math.pow(2,2*n-1)+Math.pow(2,n-1))%1000000007;
      System.out.println(k);
   }
}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

public class A {
    public static final int MOD = 1000000007;
    public static void main(String[] args) throws IOException {
        BufferedReader scan = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
        int n = Integer.parseInt(scan.readLine());
        pw.println(((n % MOD) * ((2*(n % MOD) % MOD) + 1) % MOD) % MOD);
        pw.flush();
        pw.close();
    }
}

import java.util.*;

public class Plant185A
{
    public static long twopower(long exp)
    {
        if (exp == 0)
        {
            return 0;
        }
        if (exp == 1)
        {
            return 2;
        }
        if (exp % 2 == 0)
        {
            long recurs = twopower(exp/2);
            return (recurs * recurs)%1000000007;
        }
        else   // exp % 2 == 1
        {
            long recurs = twopower(exp/2);
            long onemult = (recurs * recurs) % 1000000007;
            return (onemult * 2)%1000000007;
        }
    }

    public static void main(String[] args)
    {

        // Set up scanner
        Scanner sc = new Scanner(System.in);
        // System.out.println("Enter n");
        long n = sc.nextLong();

        if (n==1)
        {
            System.out.println(3);
            return;
        }

        long firstpart = twopower(n);
        long answer = ((firstpart+1)*(firstpart/2))%1000000007;
        System.out.println(answer);
    }
}

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

import static java.lang.Math.log;
import static java.lang.Math.max;
import static java.lang.Math.pow;

public class CF186C {
    static public void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                CF186C.run();
            }
        }, "1", 16 * (1 << 20)).start();
    }

    static void run() {
        Scanner scanner = new Scanner(System.in);
        try {
            long n = scanner.nextLong();
            long res = (pow2(n * 2 - 1) + pow2(n - 1)) % 1000000007;
            System.out.println(res);
        }

        finally {
            scanner.close();
        }
    }

    static long[] d = new long[128]; // d[i] is 2 ^ (2 ^ i)
    static {
        d[0] = 2;
        for (int i = 1; i < d.length; i++)
            d[i] = (d[i - 1] * d[i - 1]) % 1000000007;
    }

    static long pow2(long p) {
        if (p <= 60) {
            return 1 << p;
        }
        int log2 = (int)(log(p)/log(2));
        return (d[log2] * pow2(p - 1 << log2)) % 1000000007;
    }
}

import java.util.Scanner;

public class C {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long num = sc.nextLong();

        if(num == 0)
            System.out.println(1);
        else
            System.out.println(num * (2 * num + 1));
    }

}

import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main{
    public static int MOD = 1000000007;
    public static void main(String args[])throws Exception{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine().trim();
        long n = Long.parseLong(s);
        if(n==0)System.out.print(0);
        else{
        long a = binPow(2,2*n-1);
        long b = binPow(2,n-1);
        System.out.print((a+b)%MOD);}
    }
    public static long binPow(int n,long pow){
        if(pow==0)return 1;
        if(pow==1)return n;
        if(pow%2==0){
            long v = binPow(n, pow/2)%MOD;
            return (v*v)%MOD;
        }
        else{
            long v = binPow(n, pow/2)%MOD;
            return (((v*2)%MOD)*v)%MOD;
        }
    }
}

import java.util.*;
public class C {

    public void doIt(){
        final int MOD = 1000000007;
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long ans = (long) (Math.pow(2, n % MOD - 1) + Math.pow(2, (long)2 * n % MOD - 1)) ;
        System.out.println((long) (Math.pow(2, n % MOD - 1)));
        System.out.println((long)Math.pow(2, n % MOD * 2 - 1));
        System.out.println(ans % MOD);

    }
    public static void main(String[] args) {
        C obj = new C();
        obj.doIt();

    }

}

import java.util.Scanner;

public class Prob185A {
	public static void main(String[] Args) {
		Scanner in = new Scanner(System.in);
		int mod = 1000000007;
		long years = in.nextLong() % mod;
		long rows = 1;
		for (int i = 1; i < years; i++)
			rows = (rows * 2) % mod;
		long answer = rows * (rows + 1) /2;
		System.out.println(answer % mod);
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;

public class kok {
	static long MOD = 1000000007;

	static long fastPower(long a, long b){
		long res = 1;

		while(b > 0){
			if(b % 2 == 1)
				res = res * a % MOD;
			a = (a * a) % MOD;
			b /= 2;
		}

		return res % MOD;

	}

	public static void main(String[] args) throws IOException {
		FastReader sc = new FastReader(System.in);

		//System.out.println(fastPower(2, 4));

		long year = sc.nextL();

		System.out.println((fastPower(2, year - 1) * (fastPower(2, year) + 1)) % MOD);

  }

}

class FastReader {
	public BufferedReader reader;
    public StringTokenizer tokenizer;

    public FastReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() throws IOException{
        return Integer.parseInt(next());
    }
     public long nextL() throws IOException{
        return Long.parseLong(next());
    }
}

import java.math.BigInteger;
import java.util.Scanner;

public class coA {

    public static void main(String a[])
    {
        Scanner in = new Scanner(System.in);
        while(in.hasNext())
        {
            BigInteger mod,n,four,ans,two;
            mod = BigInteger.valueOf(1000000007);
            n = in.nextBigInteger();

            if(n.equals(BigInteger.ZERO))
                System.out.println("1");
            else
            {
                four=BigInteger.valueOf(4);
                two=BigInteger.valueOf(2);
                ans = four.modPow(n, mod).add(two.modPow(n, mod));
                ans = ans.divide(two);
                System.out.println(ans);
            }
            break;

        }
    }
}

import java.util.*;
import java.io.*;
import java.math.*;

public class C {
    public static StreamTokenizer in = new StreamTokenizer(System.in);
    public static boolean bg = true;

    public static void main(String[] args) throws Exception {
        long n1 = nl();
        if (n1 == 0){
            pn(1);
            ex();
        }
        MOD m1 = new MOD(1000000007);
        long k1 = m1.pow(2, n1-1);
        long k2 = m1.pow(2, n1);
        k2 = m1.a(1, k2);
        long fin = m1.t(k1, k2);
        pn(fin);
    }
    public static class MOD {
        public long mod = -1;
        public MOD(long k1){
            mod = k1;
        }
        public long a(long n1, long n2){
            return (n1+n2)%mod;
        }
        public long s(long n1, long n2){
            long k1 = (n1-n2)%mod;
            if (k1<0) k1+= mod;
            return k1;
        }
        public long t(long n1, long n2){
            long k1 = (n1*n2)%mod;
            if (k1<0) k1+=mod;
            return k1;
        }
        public long d(long n1, long n2){
            return (t(n1,xgcd(mod,n2)))%mod;
        }
        public static long xgcd(long n1, long n2){
            long k1 = n1;
            long k2 = n2;
            long[] l1 = {1,0};
            long[] l2 = {0,1};
            for (;;){
                long f1  = k1/k2;
                long f2 = k1%k2;
                if (f2==0) break;

                long[] l3 = {0,0};
                l3[0] = l1[0]- f1*l2[0];
                l3[1] = l1[1]- f1*l2[1];
                l1 = l2;
                l2 = l3;

                k1 = k2;
                k2 = f2;
            }
            long fin = l2[1]%n1;
            if (fin<0){
                fin+=n1;
            }
            return fin;
        }
        public long pow(long n1, long pow){
            if (pow==0) return 1;
            else if (pow==1) return t(1l,n1);
            else if (pow%2==0){
                long half = pow(n1,pow/2);
                return t(half,half);
            }
            else {
                long half = pow(n1,pow/2);
                return t(half,t(half,n1));
            }
        }
    }

    public static int ni() throws Exception {
        in.nextToken();
        return (int) in.nval;
    }

    public static long nl() throws Exception {
        in.nextToken();
        return (long) in.nval;
    }

    public static double nd() throws Exception {
        in.nextToken();
        return in.nval;
    }

    public static String ns() throws Exception {
        in.nextToken();
        return in.sval;
    }

    public static int[] intl(int n1) throws Exception {
        int[] fin = new int[n1];
        for (int i = 0; i < n1; i++) {
            fin[i] = ni();
        }
        return fin;
    }

    public static long[] longl(int n1) throws Exception {
        long[] fin = new long[n1];
        for (int i = 0; i < n1; i++) {
            fin[i] = nl();
        }
        return fin;
    }

    public static double[] doublel(int n1) throws Exception {
        double[] fin = new double[n1];
        for (int i = 0; i < n1; i++) {
            fin[i] = nd();
        }
        return fin;
    }

    public static void pn(Object o1) {
        System.out.println(o1);
    }

    public static void p(Object o1) {
        System.out.print(o1);
    }

    public static void ex() {
        System.exit(0);
    }
}

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;

public class Main {
	static BufferedReader br;
	static StringTokenizer st;
	static PrintWriter pw;

	public static void main(String[] args) throws IOException	{
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		//185A: 2^(n-1)*(1+2^n)
		long n = readLong();
		long a = pow(2, n-1, 1000000007);
		long b = 1 + pow(2, n, 1000000007);
		pw.println((a*b)%1000000007);
		pw.close();
	}

	public static long pow(long b, long e, long m)	{
		long r = 1;
		while(e > 0)	{
			if(e%2==1)	{
				r *= b;
				r %= m;
			}
			b *= b;
			b %= m;
			e >>= 1;
		}
		return r;
	}

	public static long readLong() throws IOException	{
		return Long.parseLong(nextToken());
	}
	public static double readDouble() throws IOException	{
		return Double.parseDouble(nextToken());
	}
	public static int readInt() throws IOException	{
		return Integer.parseInt(nextToken());
	}
	public static short readShort() throws IOException	{
		return Short.parseShort(nextToken());
	}
	public static String nextToken() throws IOException	{
		while(st == null || !st.hasMoreTokens())	{
			if(!br.ready())	{
				pw.close();
				System.exit(0);
			}
			st = new StringTokenizer(br.readLine());
		}
		return st.nextToken();
	}
}

import java.math.BigInteger;

public class p185a {
	static final java.util.Scanner sin = new java.util.Scanner(System.in);
	static final java.io.PrintStream sout = System.out;

	static BigInteger[] table = {
		new BigInteger("1"),
		new BigInteger("2"),
		new BigInteger("4"),
		new BigInteger("8"),
		new BigInteger("16"),
		new BigInteger("32"),
		new BigInteger("64"),
		new BigInteger("128"),
		new BigInteger("256"),
		new BigInteger("512"),
		new BigInteger("1024"),
		new BigInteger("2048"),
		new BigInteger("4096"),
		new BigInteger("8192"),
		new BigInteger("16384"),
		new BigInteger("32768"),
		new BigInteger("65536"),
		new BigInteger("131072"),
		new BigInteger("262144"),
		new BigInteger("524288"),
		new BigInteger("1048576"),
		new BigInteger("2097152"),
		new BigInteger("4194304"),
		new BigInteger("8388608"),
		new BigInteger("16777216"),
		new BigInteger("33554432"),
		new BigInteger("67108864"),
		new BigInteger("134217728"),
		new BigInteger("268435456"),
		new BigInteger("536870912"),
		new BigInteger("1073741824"),
		new BigInteger("2147483648"),
		new BigInteger("4294967296"),
		new BigInteger("8589934592"),
		new BigInteger("17179869184"),
		new BigInteger("34359738368"),
		new BigInteger("68719476736"),
		new BigInteger("137438953472"),
		new BigInteger("274877906944"),
		new BigInteger("549755813888"),
		new BigInteger("1099511627776"),
		new BigInteger("2199023255552"),
		new BigInteger("4398046511104"),
		new BigInteger("8796093022208"),
		new BigInteger("17592186044416"),
		new BigInteger("35184372088832"),
		new BigInteger("70368744177664"),
		new BigInteger("140737488355328"),
		new BigInteger("281474976710656"),
		new BigInteger("562949953421312"),
		new BigInteger("1125899906842624"),
		new BigInteger("2251799813685248"),
		new BigInteger("4503599627370496"),
		new BigInteger("9007199254740992"),
		new BigInteger("18014398509481984"),
		new BigInteger("36028797018963968"),
		new BigInteger("72057594037927936"),
		new BigInteger("144115188075855872"),
		new BigInteger("288230376151711744"),
		new BigInteger("576460752303423488"),
		new BigInteger("1152921504606846976")
	};
	static long[] mods = {
		2,
		4,
		16,
		256,
		65536,
		294967268,
		582344008,
		279632277,
		792845266,
		418385479,
		812734592,
		409643880,
		246797651,
		112754241,
		774491455,
		669157962,
		973586826,
		125655169,
		385894014,
		998632880,
		36221046,
		164150368,
		125918023,
		405241093,
		306292255,
		816280417,
		513497891,
		215687307,
		75265151,
		915398907,
		71108578,
		829787081,
		974674403,
		213475114,
		978311635,
		476717689,
		414682450,
		134271769,
		824187012,
		994498569,
		819855989,
		994021262,
		391524810,
		772494375,
		229407740,
		803512230,
		240149607,
		338551618,
		248097545,
		404160288,
		252824185,
		73473749,
		754326264,
		577140940,
		292441966,
		879289042,
		969233273,
		914400619,
		174683759,
		444769176
	};
	public static void main(String args[]) {
		BigInteger n = new BigInteger(sin.nextLine());
		BigInteger n1 = n.subtract(BigInteger.ONE);
		long mod = 1;
		for (int i=table.length-1; i>=0; i--) {
			if (table[i].compareTo(n1)<=0) {
				n1 = n1.subtract(table[i]);
				mod = (mod*mods[i])%1000000007;
			}
		}
		long mod2 = (mod*2+1)%1000000007;
		//System.out.println(mod + " " + mod2);
		System.out.println((mod*mod2)%1000000007);
	}

	public static void generateTable() {
		BigInteger two = new BigInteger("2");
		BigInteger n = new BigInteger("2");
		long mod = 2;
		for (int i=0; i<60; i++) {
			System.out.println(n.toString() + "\t" + mod);
			//System.out.println("\t\tnew BigInteger(\"" + n.toString() + "\"),");
			//System.out.println("\t\t" + mod + ",");
			n = n.multiply(two);
			mod = (mod*mod)%1000000007;
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Plant {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        long year = Long.parseLong(reader.readLine());
        if (year == 0) {
            System.out.println(1);
        } else {
            System.out.println(((year * 2) * ((year * 2) + 1)) / 2);
        }
        reader.close();
    }
}

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.StringTokenizer;

public class Main {
    Scanner in;
    PrintWriter out;

    void setIn(String fI) {

        try {
            in = new Scanner(new FileInputStream(new File(fI)));
        } catch (FileNotFoundException e) {
            throw new Error(e);
        }
    }

    void setIn() {
        in = new Scanner(System.in);
    }

    void setOut(String fO) {
        try {
            out = new PrintWriter(new FileWriter(fO));
        } catch (IOException e) {
            throw new Error(e);
        }
    }

    void setOut() {
        out = new PrintWriter(System.out);
    }

    class Scanner {
        StringTokenizer st;
        BufferedReader in;
        String del;

        Scanner(InputStream is) {
            in = new BufferedReader(new InputStreamReader(is));
            st = null;
            del = " \t\n\r\f";
        }

        void setDelimiters(String del) {
            this.del = del;
        }

        String next() {
            if (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(nextLine(), del);
            }
            return st.nextToken();
        }

        String nextLine() {
            try {
                st = null;
                return in.readLine();
            } catch (IOException e) {
                throw new Error(e);
            }
        }

        boolean hasNext() {
            try {
                return in.ready() || (st != null && st.hasMoreTokens());
            } catch (IOException e) {
                throw new Error(e);
            }
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }

        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }

        int[] nextIntArray(int len) {
            int[] a = new int[len];
            for (int i = 0; i < len; i++) {
                a[i] = nextInt();
            }
            return a;
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        setIn();
        setOut();
        try {
            solve();
        } finally {
            out.close();
        }
    }

    class G {
        int a;
        int b;
        int in;
        double res;

        G(int A, int B, int I) {
            a = A;
            b = B;
            in = I;
        }
    }

    BigInteger mod = new BigInteger("1000000007");

    void solve() {
        BigInteger n = new BigInteger(Long.toString(in.nextLong()));
        if (n.equals(BigInteger.ZERO)) {
            out.println(1);
            return;
        }
        out.println(n.multiply(BigInteger.valueOf(2).multiply(n).add(BigInteger.ONE)).mod(mod));

    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class C implements Runnable {

	final long MOD = 1000000000 + 7;

	private void Solution() throws IOException {
		long n = nextLong();
		long f = binpow(4, n) % MOD;
		long t = binpow(2, n) % MOD;
		long ans = ((f + t) / 2) % MOD;
		print(ans);
	}

	long binpow1(long a, long n) {
		long res = 1;
		while (n != 0) {
			if (n % 2 == 1) {
				res *= a;
				res %= MOD;
			}
			a *= a;
			a %= MOD;
			n >>= 1;
		}
		return res;
	}

	long binpow(long a, long n) {
		if (n == 0)
			return 1;
		if (n % 2 == 1)
			return binpow(a, n - 1) * a % MOD;
		else {
			long b = binpow(a, n / 2) % MOD;
			return b * b % MOD;
		}
	}

	public static void main(String[] args) {
		new C().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer tokenizer;

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			Solution();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(0);
		}
	}

	void print(Object... o) {
		for (int i = 0; i < o.length; i++) {
			if (i != 0)
				out.print(" ");
			out.print(o[i]);
		}
	}

	void println(Object... o) {
		for (int i = 0; i < o.length; i++) {
			if (i != 0)
				print(" ");
			print(o[i]);
		}
		print("\n");
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	long nextLong() throws NumberFormatException, IOException {
		return Long.parseLong(next());
	}

	double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(next());
	}

	String nextLine() throws IOException {
		return in.readLine();
	}

	String next() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(nextLine());
		return tokenizer.nextToken();
	}
}

import java.math.BigInteger;
import java.util.Scanner;

public class B {
    public static void main(String[] args) {
        Scanner theIn=new Scanner(System.in);
        String n=theIn.next();
        if (n.equals("1")) System.out.println("1"); else {
            BigInteger t=find(new BigInteger(n));
            BigInteger s=((t.add(new BigInteger("1"))).multiply(t).divide(new BigInteger("2"))).mod(new BigInteger("1000000007"));
            System.out.println(s);
        }

    }

    static BigInteger find(BigInteger n) {
        BigInteger two=new BigInteger("2");
        if (n.equals(new BigInteger("1"))) return two;
        BigInteger k=find(n.divide(two)).mod(new BigInteger("1000000007"));
        if (n.mod(two).equals(new BigInteger("1"))) return two.multiply(k.multiply(k)).mod(new BigInteger("1000000007")); else return k.multiply(k).mod(new BigInteger("1000000007"));
    }
}

import java.util.*;
public class b
{
    static int p = (int) 1e9 + 7;
    static int Infinity=Integer.MAX_VALUE;
    static int negInfinity=Integer.MIN_VALUE;
    public static void main(String args[])
    {
        Scanner d= new Scanner(System.in);
        long n;
        n=d.nextLong();
        if(n==0)
        System.out.println(0);
        else
        System.out.println((power(n-1)%p)*((power(n)+1l)%p)%p);
    }
    static long power(long n1)
        {
        long res=1l;
        long x=2l;
        while(n1>0)
        {
            if((n1&1)==1)
            res=(res*x)%p;
            n1>>=1;
            x=(x*x)%p;
        }
        return res;
    }
}
/////////////System.out.println("Case #"+i+": "+c);

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import java.util.StringTokenizer;

public class CFC {
    BufferedReader br;
    PrintWriter out;
    StringTokenizer st;
    boolean eof;
    final long MOD = 1000L * 1000L * 1000L + 7;

    void solve() throws IOException {
        long n = nextLong();
        int[][] mat = {{3, 1}, {1, 3}};
        int[][] res = pow(mat, n);
        out(res[0][0] % MOD);
    }

    int[][] pow(int[][] m, long p) {
        if (p == 0) {
            return new int[][]{{1, 0}, {0, 1}};
        }

        if (p % 2 == 0) {
            return pow(multiply(m, m), p / 2);
        }
        else {
            int[][] res = pow(multiply(m, m), p / 2);
            return multiply(res, m);
        }
    }

    int[][] multiply(int[][] m1, int[][] m2) {
        int n = 2;
        int[][] res = new int[n][n];
        res[0][0] = m1[0][0] * m2[0][0] + m1[0][1] * m2[0][1];
        res[0][1] = m1[0][0] * m2[0][1] + m1[0][1] * m2[1][1];
        res[1][0] = m1[1][0] * m2[0][0] + m1[1][1] * m2[1][0];
        res[1][1] = m1[1][0] * m2[0][1] + m1[1][1] * m2[1][1];
        res[0][0] %= MOD;
        res[0][1] %= MOD;
        res[1][0] %= MOD;
        res[1][1] %= MOD;
        return res;
    }

    void shuffle(int[] a) {
        int n = a.length;
        for(int i = 0; i < n; i++) {
            int r = i + (int) (Math.random() * (n - i));
            int tmp = a[i];
            a[i] = a[r];
            a[r] = tmp;
        }
    }
    private void outln(Object o) {
        out.println(o);
    }
    private void out(Object o) {
        out.print(o);
    }
    public CFC() throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }
    public static void main(String[] args) throws IOException {
        new CFC();
    }

    public long[] nextLongArr(int n) throws IOException{
        long[] res = new long[n];
        for(int i = 0; i < n; i++)
            res[i] = nextLong();
        return res;
    }
    public int[] nextIntArr(int n) throws IOException {
        int[] res = new int[n];
        for(int i = 0; i < n; i++)
            res[i] = nextInt();
        return res;
    }
    public String nextToken() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                eof = true;
                return null;
            }
        }
        return st.nextToken();
    }
    public String nextString() {
        try {
            return br.readLine();
        } catch (IOException e) {
            eof = true;
            return null;
        }
    }
    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    public double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;

public class kok {
	static long MOD = 1000000007;

	static long fastPower(long a, long b){
		long res = 1;

		while(b > 0){
			if(b % 2 == 1)
				res = res * a % MOD;
			a = (a * a) % MOD;
			b /= 2;
		}

		return res % MOD;

	}

	public static void main(String[] args) throws IOException {
		FastReader sc = new FastReader(System.in);

		//System.out.println(fastPower(2, 4));

		long year = sc.nextL();

		System.out.println((fastPower(2, year - 1) + fastPower(2, year)) % MOD);

  }

}

class FastReader {
	public BufferedReader reader;
    public StringTokenizer tokenizer;

    public FastReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() throws IOException{
        return Integer.parseInt(next());
    }
     public long nextL() throws IOException{
        return Long.parseLong(next());
    }
}

import java.util.Scanner;

public class ProblemC {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int t = (int) Math.pow(2, n);
        t*=t-t/2+0.5;
        System.out.println(t % 1000000007);
    }
}

import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;

public class C118 {
        public static void main(String[] args) {
                InputStream inputStream = System.in;
                OutputStream outputStream = System.out;
                InputReader in = new InputReader(inputStream);
                PrintWriter out = new PrintWriter(outputStream);
                CodeC118 solver = new CodeC118();
                solver.solve(1, in, out);
				//long n=(long)100000000*(long)100000000;
				//out.println(solver.convert(n)+" for "+n);
                out.close();
        }
}

class CodeC118
{
public void solve(int testNumber, InputReader in, PrintWriter out)
{
	long mod=1000000007;
	long n=in.nextLong();
	long ans = (pow(2*n-1)%mod+pow(n-1)%mod)%mod;
	out.println(ans);
}
public long pow(long p)
{
	long mod=1000000007;
	long ret=1;
	long arr[]=new long[75];
	arr[0]=2;
	for(int i=1;i<arr.length;i++)
	{
		arr[i]=(arr[i-1]*arr[i-1])%mod;
	}
	String s=convert(p);
	// System.out.println(s);
	for(int i=0;i<s.length();i++)
	{
		if(s.charAt(i)=='1')
		{
			ret=(ret*arr[s.length()-i-1])%mod;
		}
	}
	return ret;
}
public String convert(long n)
{
	//System.out.println("Read "+n);
	String num="";
	long t=0;
	while(n!=0)
	{
		num=String.valueOf(n%2)+num;
		//System.out.println(num);
		n/=2;
		t++;
	}
	return num;
	}
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }
	public void inputShuffleArrayInt(int arr[])
	{
		int l=arr.length;
		for(int i=0;i<l;i++)
		{
			if(i%2==0)
			{
				arr[i/2]=nextInt();
			}
			else
			{
				arr[l-((i+1)/2)]=nextInt();
			}
		}
	}

    }

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Solution{

    ///////////////////////////////////////////////////////////////////////////
    static class FastScanner{
        BufferedReader s;
        StringTokenizer st;

        public FastScanner(InputStream InputStream){
            st = new StringTokenizer("");
            s = new BufferedReader(new InputStreamReader(InputStream));
        }

        public FastScanner(File f) throws FileNotFoundException{
            st = new StringTokenizer("");
            s = new BufferedReader (new FileReader(f));
        }

        public int nextInt() throws IOException{
            if(st.hasMoreTokens())
                return Integer.parseInt(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextInt();
            }
        }

        public double nextDouble() throws IOException{
            if(st.hasMoreTokens())
                return Double.parseDouble(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextDouble();
            }
        }

        public long nextLong() throws IOException{
            if(st.hasMoreTokens())
                return Long.parseLong(st.nextToken());
            else{
                st = new StringTokenizer(s.readLine());
                return nextLong();
            }
        }

        public String nextString() throws IOException{
            if(st.hasMoreTokens())
                return st.nextToken();
            else{
                st = new StringTokenizer(s.readLine());
                return nextString();
            }

        }
        public String readLine() throws IOException{
            return s.readLine();
        }

        public void close() throws IOException{
            s.close();
        }

    }

    ////////////////////////////////////////////////////////////////////
    //      Number Theory

    long pow(long a,long b,long mod){
        long x = 1; long y = a;
        while(b > 0){
            if(b % 2 == 1){
                x = (x*y);
                x %= mod;
            }
            y = (y*y);
            y %= mod;
            b /= 2;
        }
        return x;
    }

    int divisor(long x,long[] a){
        long limit = x;
        int numberOfDivisors = 0;

        for (int i=1; i < limit; ++i) {
            if (x % i == 0) {
                limit = x / i;
                if (limit != i) {
                    numberOfDivisors++;
                }
                numberOfDivisors++;
            }
        }
        return numberOfDivisors;
    }

    void findSubsets(int array[]){
        long numOfSubsets = 1 << array.length;
        for(int i = 0; i < numOfSubsets; i++){
            int pos = array.length - 1;
            int bitmask = i;
            while(bitmask > 0){
                if((bitmask & 1) == 1)
                    ww.print(array[pos]+" ");
                bitmask >>= 1;
                pos--;
            }
            ww.println();
        }
    }

    public static long gcd(long a, long b){
        return b == 0 ? a : gcd(b,a%b);
    }

    public static int lcm(int a,int b, int c){
        return lcm(lcm(a,b),c);
    }

    public static int lcm(int a, int b){
        return (int) (a*b/gcd(a,b));
    }

    public static long invl(long a, long mod) {
        long b = mod;
        long p = 1, q = 0;
        while (b > 0) {
            long c = a / b;
            long d;
            d = a;
            a = b;
            b = d % b;
            d = p;
            p = q;
            q = d - c * q;
        }
        return p < 0 ? p + mod : p;
    }

    ////////////////////////////////////////////////////////////////////

//    private static    FastScanner s = new FastScanner(new File("input.txt"));
//    private static PrintWriter ww = new PrintWriter(new FileWriter("output.txt"));
    static InputStream inputStream = System.in;
    static FastScanner s = new FastScanner(inputStream);
    static OutputStream outputStream = System.out;
    static PrintWriter ww = new PrintWriter(new OutputStreamWriter(outputStream));
//      private static Scanner s = new Scanner(System.in);
    @SuppressWarnings("unused")
    private static int[][] states = { {-1,0} , {1,0} , {0,-1} , {0,1} };

    ////////////////////////////////////////////////////////////////////

    public static void main(String[] args) throws IOException{
        new Solution().solve();
        s.close();
        ww.close();
    }

    ////////////////////////////////////////////////////////////////////

    void solve() throws IOException{

        long mod = (long)1e9+7;

        long n = s.nextLong();
        if(n == 0) ww.println(0);
        else
        ww.println(pow(2,n-1,mod)*(1+pow(2,n,mod)));

    }
}

//import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Scanner;

public class B {
	static BigInteger nb = new BigInteger("1000000007");

	public static String rightToLeftBinary(String a, String b) {
		BigInteger ab = new BigInteger(a);
		BigInteger bb = new BigInteger(b);

		BigInteger t = BigInteger.valueOf(Integer.MAX_VALUE);
		int i = 0;
		while (bb.compareTo(t) == 1) {
			bb = bb.divide(BigInteger.valueOf(Integer.MAX_VALUE));
			i++;
		}
		int l = bb.intValue();
		t = BigInteger.valueOf(1);
		for (int j = 0; j <= i; j++)
			while (l > 0) {
				if ((l & 1) == 1)
					t = t.multiply(ab).mod(nb);
				l = l >> 1;
				ab = ab.multiply(ab).mod(nb);
			}
		return t.toString();
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		String t = rightToLeftBinary("2", x);
		BigInteger b = new BigInteger(t);
		BigInteger c = b.add(BigInteger.valueOf(1));
		c = c.multiply(b).mod(nb);
		c = c.divide(BigInteger.valueOf(2));
		System.out.println(c);
	}
}

import java.io.*;
import java.util.*;

public class A {
	private static class Solver {
		public void run() throws IOException {
			int u = 1, d = 0;
			final int n = IOFast.nextInt();
			long[][] mat = new long[][] {
					new long[] { 3, 1 },
					new long[] { 1, 3 },
			};
			final int mod = (int)1e9+7;
			mat = powmat(n, mod, mat);
			IOFast.out.println(mat[0][0]);
			// u' = u * 3 + d, d' = u + d * 3
		}
	}

	public static void main(String[] args) throws IOException {
		new Solver().run();
		IOFast.out.flush();
	}

	// long
	// a [n,v] * b [v,m] => c[n,m]
	static long[][] mulmat(long[][] a, long[][] b, int mod) {
		assert(a[0].length == b.length);

		final int n = a.length;
		final int v = b.length;
		final int m = b[0].length;

		long[][] res = new long[n][m];
		for(int i = 0; i < n; i++)
			for(int j = 0; j < m; j++)
				for(int k = 0; k < v; k++)
					res[i][j] = (res[i][j] + a[i][k] * b[k][j]) % mod;

		return res;
		/*
		long[][] res = new long[n][n];
		for(int i = 0; i < n; i++)
			for(int j = 0; j < n; j++)
				for(int k = 0; k < n; k++)
					res[i][j] = (res[i][j] + a[i][k] * b[k][j]) % mod;
		return res;
		*/
	}

	static long[][] powmat(int r, int mod, long[][] mat) {
		final int n = mat.length;
		long[][] x = new long[n][n];
		for(int i = 0; i < n; i++) {
			x[i][i] = 1;
		}

		for(;r > 0; r >>>= 1) {
			if((r&1) == 1) {
				x = mulmat(x, mat, mod);
			}
			mat = mulmat(mat, mat, mod);
		}

		return x;
	}

	static public class IOFast {
		private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		private static PrintWriter out = new PrintWriter(System.out);

//		private static final int BUFFER_SIZE = 50 * 200000;
		private static final StringBuilder buf = new StringBuilder();
		private static boolean[] isDigit = new boolean[256];
		private static boolean[] isSpace = new boolean[256];

		static {
			for(int i = 0; i < 10; i++) {
				isDigit['0' + i] = true;
			}
			isDigit['-'] = true;
			isSpace[' '] = isSpace['\r'] = isSpace['\n'] = isSpace['\t'] = true;
		}

		static boolean endInput;

		private static int nextInt() throws IOException {
			boolean plus = false;
			int ret = 0;
			while(true) {
				final int c = in.read();

				if(c == -1) {
					endInput = true;
					return Integer.MIN_VALUE;
				}

				if(isDigit[c]) {
					if(c != '-') {
						plus = true;
						ret = c - '0';
					}
					break;
				}
			}

			while(true) {
				final int c = in.read();
				if(c == -1 || !isDigit[c]) {
					break;
				}
				ret = ret * 10 + c - '0';
			}

			return plus ? ret : -ret;
		}

		private static long nextLong() throws IOException {
			boolean plus = false;
			long ret = 0;
			while(true) {
				final int c = in.read();

				if(c == -1) {
					endInput = true;
					return Integer.MIN_VALUE;
				}

				if(isDigit[c]) {
					if(c != '-') {
						plus = true;
						ret = c - '0';
					}
					break;
				}
			}

			while(true) {
				final int c = in.read();
				if(c == -1 || !isDigit[c]) {
					break;
				}
				ret = ret * 10 + c - '0';
			}

			return plus ? ret : -ret;
		}

		private static String next() throws IOException {
			buf.setLength(0);

			while(true) {
				final int c = in.read();

				if(c == -1) {
					endInput = true;
					return "-1";
				}

				if(!isSpace[c]) {
					buf.append((char)c);
					break;
				}
			}

			while(true) {
				final int c = in.read();

				if(c == -1 || isSpace[c]) {
					break;
				}
				buf.append((char)c);
			}

			return buf.toString();
		}

		private static double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

	}

}

import java.math.BigInteger;
import java.util.Scanner;

public class A {
    public static void main(String args[]){
        int M=1000000007;
        Scanner s=new Scanner(System.in);
        long n= s.nextLong();
        if(n==0){
            System.out.print(1);
        }else{
            BigInteger a=new BigInteger("2");
            a=a.modPow(new BigInteger(String.valueOf(n)), new BigInteger(String.valueOf(M)));
            BigInteger b=new BigInteger("2");
            b=b.modPow(new BigInteger(String.valueOf(n-1)), new BigInteger(String.valueOf(M)));
            System.out.print((a.add(b)).mod(new BigInteger(String.valueOf(M))).longValue());
        }
    }
}

import java.util.Scanner;

public class Main
{//main

  static long p2(long n){
      long p=1;
      while (n>60){
          p=p*((1<<60)%1000000007);
          n=n-60;
      }
      p=p*(1<<n)%1000000007;
      /*for (long i=1;i<=n;i++){
          p=p*2%1000000007;
      }
       *
       */
      return p;
  }

  public static void main (String[] args) throws java.lang.Exception
  {// Reading strings using Scanner
   Scanner scan = new Scanner(System.in);
   long n = scan.nextLong();

   if (n==0){
       System.out.println("1");
   } else{
     /*kp=1;
     kn=0;
     for (int i=1;i<=n;i++){
         kp0=kp;
         kn0=kn;
         kp=3*kp0+kn0;
         kn=3*kn0+kp0;
         System.out.println(kp+" "+kn);
     }
      *
      */
      long a,b;
      a=p2(n-1);
      b=a*2+1;
      a=a*b%1000000007;

     System.out.println(a);
   }

  }
}

import java.util.Scanner;

public class C {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long num = sc.nextLong();
        num = num * 2;

        if(num == 0)
            System.out.println(1);
        else {
            num= (((num) * (num + 1)) / 2) % 1000000007L;
            if(num<0)
                num+=1000000007L;

            System.out.println(num);
        }
    }

}

import java.math.BigInteger;
import java.util.Scanner;

public class C {

    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        BigInteger e1 = BigInteger.valueOf(n);
        BigInteger e2 = BigInteger.valueOf(n-1);
        BigInteger m = BigInteger.valueOf(1000000007);
        System.out.println(BigInteger.valueOf(2).modPow(e2, m).multiply(BigInteger.valueOf(1).add(BigInteger.valueOf(2).modPow(e1, m))));
    }
}

import java.io.*;
import java.net.URL;
import java.util.*;

public class Template implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine(), " :");
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    public static void main(String[] args) {
        new Template().run();
        // new Thread(null, new Template(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    int mod = (int) 1e9 + 7;

    long[][] mul(long[][] a, long[][] b) {
        int n = a.length;
        long[][] c = new long[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    c[i][j] += a[i][k] * b[k][j];
                }
                c[i][j] %= mod;
            }
        }
        return c;
    }

    long[][] pow(long[][] a, long p) {
        if (p == 1) {
            long[][] res = new long[a.length][a.length];
            res[0][0] = res[1][1] = 1;
            return res;
        }
        if (p == 1) return a;
        if (p % 2 == 0) {
            long[][] half = pow(a, p / 2);
            return mul(half, half);
        } else {
            return mul(a, pow(a, p - 1));
        }
    }

    void solve() throws IOException {
        long[][] matr = new long[2][2];
        matr[0][0] = matr[1][1] = 3;
        matr[1][0] = matr[0][1] = 1;
        matr = pow(matr, readLong());
        out.println(matr[0][0]);
    }

}

/*
http://codeforces.com/problemset/problem/185/A
 *
 * @author Hardik
 */
import java.io.*;
import java.util.*;

public class codeforce {

    public static void main (String args []) throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long n = Long.parseLong(br.readLine());
        System.out.println(plant(n));

    }

    static long [] [] multiply(long [][] M, long [] [] N)
    {
        long [][] F  = new long[2][2];

        F[0][0] = (M[0][0]*N[0][0] + M[1][0]*N[0][1])%1000000007;
        F[1][0] = (M[0][0]*N[1][0] + M[1][0]*N[1][1])%1000000007;
        F[0][1] = (M[0][1]*N[0][0] + M[1][1]*N[0][1])%1000000007;
        F[1][1] = (M[0][1]*N[1][0] + M[1][1]*N[1][1])%1000000007;

        return F;
    }

    static void debug (Object...oe)
    {
        System.out.println(Arrays.deepToString(oe));
    }

    static long plant(long n )
    {
        long [][] ans = {{1,0},{0,1}};
        long [][] M = {{3,1},{1,3}};
        long log = (long) Math.floor(Math.log10(n)/Math.log10(2));
        if ((n & 1) == 1)
            ans = multiply(ans,M);
        for(long i = 1; i <= log ; i ++)
        {
            M = multiply(M,M);
            if (((n >> 1) & 1) == 1)
                ans = multiply(ans, M);
        }
        return ans[0][0];
    }

}

import java.util.*;
import java.math.BigInteger;

public class Plant185A
{
    public static long twopower(long exp)
    {
        if (exp == 0)
        {
            return 0;
        }
        if (exp == 1)
        {
            return 2;
        }
        if (exp % 2 == 0)
        {
            long recurs = twopower(exp/2);
            return (recurs * recurs)%1000000007;
        }
        else   // exp % 2 == 1
        {
            long recurs = twopower(exp/2);
            long onemult = (recurs * recurs) % 1000000007;
            return (onemult * 2)%1000000007;
        }
    }

    public static void main(String[] args)
    {

        // Set up scanner
        Scanner sc = new Scanner(System.in);
        // System.out.println("Enter n");
        long n = sc.nextLong();

        if (n==1)
        {
            System.out.println(3);
            return;
        }

        long firstpart = twopower(n) + 1;
        long secondpart = twopower(n-1);
        BigInteger bigfirst = new BigInteger(String.valueOf(firstpart));
        System.out.println(bigfirst);
        BigInteger bigsecond = new BigInteger(String.valueOf(secondpart));
        System.out.println(bigsecond);
        BigInteger bigmod = new BigInteger("1000000007");
        System.out.println(bigmod);
        BigInteger bigproduct = bigfirst.multiply(bigsecond);
        System.out.println(bigproduct);
        BigInteger biganswer = bigproduct.mod(bigmod);

        System.out.println(biganswer);
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class C {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		long n=nextLong();
		long v=binpow(2,n);
		System.out.println(((v)*(v+1))/2 % 1000000007);
	}

	int binpow (int a, long n) {
		if (n == 0)
			return 1;
		if (n % 2 == 1)
			return (binpow (a, n-1) * a)% 1000000007;
		else {
			int b = binpow (a, n/2);
			return (b * b)% 1000000007;
		}
	}
	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void print(int a[]) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
	}

	public static void main(String args[]) throws IOException {
		new C().solution();
	}
}

import java.util.*;
import java.math.BigInteger;

public class Plant185A
{
    public static long twopower(long exp)
    {
        if (exp == 0)
        {
            return 0;
        }
        if (exp == 1)
        {
            return 2;
        }
        if (exp % 2 == 0)
        {
            long recurs = twopower(exp/2);
            return (recurs * recurs)%1000000007;
        }
        else   // exp % 2 == 1
        {
            long recurs = twopower(exp/2);
            long onemult = (recurs * recurs) % 1000000007;
            return (onemult * 2)%1000000007;
        }
    }

    public static void main(String[] args)
    {

        // Set up scanner
        Scanner sc = new Scanner(System.in);
        // System.out.println("Enter n");
        long n = sc.nextLong();

        if (n==1)
        {
            System.out.println(3);
            return;
        }

        long firstpart = twopower(n) + 1;
        long secondpart = twopower(n-1);
        BigInteger bigfirst = new BigInteger(String.valueOf(firstpart));
        // System.out.println(bigfirst);
        BigInteger bigsecond = new BigInteger(String.valueOf(secondpart));
        // System.out.println(bigsecond);
        BigInteger bigmod = new BigInteger("1000000007");
        // System.out.println(bigmod);
        BigInteger bigproduct = bigfirst.multiply(bigsecond);
        // System.out.println(bigproduct);
        BigInteger biganswer = bigproduct.mod(bigmod);

        System.out.println(biganswer);
    }
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
//package codeforce118;

import java.math.BigInteger;
import java.util.Scanner;

/**
 *
 * @author DELL
 */
public class C {
    public void solve(){

        Scanner sc = new Scanner(System.in);
        int i=0,j=0;

        int count;

        BigInteger n=sc.nextBigInteger();
        BigInteger k=new BigInteger("1000000007");

        BigInteger r = n.subtract(n.divide(k));

        Double a = r.doubleValue();
        double s = Math.pow(2, a);

        System.out.println((int)((s/2)*(s+1)));

    }

    public static void main(String[] args) {
        new C().solve();
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;

public class Task185A {

	public static void main(String... args) throws NumberFormatException,
			IOException {
		Solution.main(System.in, System.out);
	}

	static class Scanner {

		private final BufferedReader br;
		private String[] cache;
		private int cacheIndex;

		Scanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
			cache = new String[0];
			cacheIndex = 0;
		}

		int nextInt() throws IOException {
			if (cacheIndex >= cache.length) {
				cache = br.readLine().split(" ");
				cacheIndex = 0;
			}
			return Integer.parseInt(cache[cacheIndex++]);
		}

		long nextLong() throws IOException {
			if (cacheIndex >= cache.length) {
				cache = br.readLine().split(" ");
				cacheIndex = 0;
			}
			return Long.parseLong(cache[cacheIndex++]);
		}

		String next() throws IOException {
			if (cacheIndex >= cache.length) {
				cache = br.readLine().split(" ");
				cacheIndex = 0;
			}
			return cache[cacheIndex++];
		}

		void close() throws IOException {
			br.close();
		}

	}

	static class Solution {

		private static long pow2(int n) {
			if (n == 1) {
				return 1;
			}
			long retVal = pow2(n / 2);
			retVal *= retVal;
			if (n % 2 == 1) {
				retVal *= 2;
			}
			return retVal % 1000000007;
		}

		public static void main(InputStream is, OutputStream os)
				throws NumberFormatException, IOException {
			PrintWriter pw = new PrintWriter(os);
			Scanner sc = new Scanner(is);

			int n = sc.nextInt();

			long podstawa = pow2(n);

			pw.println((podstawa * (podstawa + 1) / 2) % 1000000007);

			pw.flush();
			sc.close();
		}
	}

}

import java.util.*;
import java.io.*;

public class Main {
  public static void main(String[] args) {
Scanner nerd = new Scanner (System.in);
int n = nerd.nextInt();
int up = 1;
int down = 0;

for (int i = 0; i < n; i++)
{
  int newup = up;
  up = up * 3 + down;
  down = down * 3 + newup;
}
if (n == 0)
System.out.println(0);
System.out.println(up);
  }
}

import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main{
    public static int MOD = 1000000007;
    public static void main(String args[])throws Exception{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine().trim();
        long n = Long.parseLong(s);
        long a = binPow(2,2*n-1);
        long b = binPow(2,n-1);
        if(n==0)System.out.println(1);
        else
        System.out.println(a+b);
    }
    public static long binPow(int n,long pow){
        if(pow==0)return 1;
        if(pow==1)return n;
        if(pow%2==0){
            long v = binPow(n, pow/2)%MOD;
            return (v*v)%MOD;
        }
        else{
            long v = binPow(n, pow/2)%MOD;
            return (v*v*n)%MOD;
        }
    }
}

//import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Scanner;

public class B {
	public static String rightToLeftBinary(String a, String b) {
		BigInteger ab = new BigInteger(a);
		BigInteger bb = new BigInteger(b);
		BigInteger nb = new BigInteger("1000000007");
		BigInteger t = BigInteger.valueOf(Integer.MAX_VALUE);
		int i = 0;
		while (bb.compareTo(t) == 1) {
			bb = bb.divide(BigInteger.valueOf(Integer.MAX_VALUE));
			i++;
		}
		int l = bb.intValue();
		t = BigInteger.valueOf(1);
		for (int j = 0; j <= i; j++)
			while (l > 0) {
				if ((l & 1) == 1)
					t = t.multiply(ab).mod(nb);
				l = l >> 1;
				ab = ab.multiply(ab).mod(nb);
			}
		return t.toString();
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String x = sc.nextLine();
		String t = rightToLeftBinary("2", x);
		BigInteger b = new BigInteger(t);
		BigInteger c = b.add(BigInteger.valueOf(1));
		c = c.multiply(b);
		c = c.divide(BigInteger.valueOf(2));
		System.out.println(c);
	}
}

import java.util.Scanner;
public class plant {
    public static void main(String[] args){
         Scanner s=new Scanner(System.in);
         int n=s.nextInt();
         int k=(int) Math.pow(2,n);

         int t=0;
         int y=1;
         while(t!=k){
             y+=t;
             ++t;
         }
         int u=((int)Math.pow(4,n))-y+1;
          System.out.println(u%1000000007);
    }
}

import java.util.*;
import java.io.*;
import java.math.*;

public class c {

	public static void main(String agrs[])throws Exception{
		Scanner in=new Scanner(System.in);
		long n = in.nextLong();
		long p = (long)1e9 + 7;
		/*
		long four = powerMod(4, n, ((long)1e9) + 7);
		long two = powerMod(2, n, ((long)1e9) + 7);
		System.out.println(four + " " +  (power(2, n))+ " " + two + " " + (((two/2)*(two-1)) + " " + (powerMod(2, 2*n, (long)(1e9 + 7)) - powerMod(2, n, p))/2));
		*/
		/*
		BigInteger fbig = power(BigInteger.valueOf(2), n);
		System.out.println("adsf");
		BigInteger tbig2 = fbig;
		fbig = fbig.multiply(fbig);
		BigInteger tbig1 = fbig;
		System.out.println((fbig.subtract((tbig1.subtract(tbig2)).divide(BigInteger.valueOf(2)))).mod(BigInteger.valueOf(p)));
		*/
		long fbig = powerMod(2, n, p);
		//long tbig2 = powerMod(2, n, p);
		//fbig = (fbig*fbig)%p;
		//long tbig1 = fbig;
		System.out.println(((fbig + 1)*(fbig/2))%p);

	}

	static long gcd(long a, long b) { return (b == 0 ? a : gcd(b, a % b)); }
	static long lcm(long a, long b) { return (a*b) / gcd(a, b); }

	static long power(long a, long b){
		if (b == 0) return 1;
		if (b % 2 == 1) return power(a, b-1)*b;
		else { long t = power(a, b/2); return t*t; }
	}

	static BigInteger power(BigInteger a, long b){
		if (b == 0) return BigInteger.ONE;
		if (b % 2 == 1) return power(a, b-1).multiply(a);
		else { BigInteger t = power(a, b/2); return t.multiply(t); }
	}

	static long powerMod(long a, long b, long p){
		if (b == 0) return 1;
		if (b % 2 == 1) return (powerMod(a, b-1, p)*a)%p;
		else { long t = powerMod(a, b/2, p); return (t*t)%p;}
	}

	static class point implements Comparable<point>{

		int x, y, id;

		public point(int x, int y, int id){
			this.x = x; this.y = y; this.id =id;
		}

		public int compareTo(point o) {
			if (this.x == o.x) return this.y - o.y;
			return this.x - o.x;
		}

	}

}

import java.util.*;

public class Plant185A
{
    public static long twopower(long exp)
    {
        if (exp == 0)
        {
            return 0;
        }
        if (exp == 1)
        {
            return 2;
        }
        if (exp % 2 == 0)
        {
            long recurs = twopower(exp/2);
            return (recurs * recurs)%1000000007;
        }
        else   // exp % 2 == 1
        {
            long recurs = twopower(exp/2);
            long onemult = (recurs * recurs) % 1000000007;
            return (onemult * 2)%1000000007;
        }
    }

    public static void main(String[] args)
    {

        // Set up scanner
        Scanner sc = new Scanner(System.in);
        // System.out.println("Enter n");
        long n = sc.nextLong();

        if (n==1)
        {
            System.out.println(3);
            return;
        }

        long firstpart = twopower(n);
        long answer = ((firstpart+1)*(firstpart/2))%1000000007;
        System.out.println(answer);
    }
}

import java.util.Scanner;

public class B {
    public static void main(String[] args) {
        Scanner myScanner = new Scanner(System.in);
        long in = myScanner.nextLong()+1;
        long res = (((((in + 1) % 1000000007) * ((in + 2) % 1000000007)) / 2) % 1000000007);
        System.out.println(res);
    }
}

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class B {

	static final int mod = (int)1e9 + 7;
	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		long k = sc.nextLong();
		if(k == 0)
			out.println(1);
		else
			out.println((modPow(2, k - 1) + 2 * modPow(4, k - 1) % mod) % mod);
		out.flush();
		out.close();
	}

	static int modPow(int b, long e)
	{
		long res = 1;
		while(e > 0)
		{
			if((e & 1) == 1)
				res = res * b % mod;
			b = b * b  % mod;
			e >>= 1;
		}
		return (int)res;
	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public Scanner(FileReader r){	br = new BufferedReader(r);}

		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}

		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}

		public double nextDouble() throws IOException { return Double.parseDouble(next()); }

		public boolean ready() throws IOException {return br.ready();}

	}
}

import java.io.*;
import java.util.*;

public class Main {
//	static Scanner in; static int next() throws Exception {return in.nextInt();};
//	static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;}
	static BufferedReader in;
	static PrintWriter out;

	static int mod = 1000000007;
	static int[][] start;

	static int[][] mult (int[][] a, int[][] b) {
		int[][] c = new int[2][2];
		for (int i = 0; i < 2; i++)
			for (int j = 0; j < 2; j++) {
				for (int t = 0; t < 2; t++) c[i][j] += (int)(((long)a[t][i] * b[j][t]) % mod);
				c[i][j] %= mod;
			}
		return c;
	}

	static int[][] pow(int[][] x, long k) {
		if (k == 0) return new int[][] {new int[] {1, 0}, new int[] {0, 1}};
		if (k == 1) return x;

		int[][] y = pow(x, k/2);
		int[][] z = mult(y, y);
		if (k % 2 == 0) return z;

		int[][] res = mult(z, x);

		return res;
	}

	public static void main(String[] args) throws Exception {
//		in = new Scanner(System.in);
//		in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);

		long n = Long.parseLong(in.readLine());

		start = new int[][] {new int[] {3, 1}, new int[] {1, 0}};

		int[][] res = pow(start, n);

		out.println((res[0][0]) % mod);

		out.close();
	}
}

import java.util.Scanner;

public class ProblemC {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int t = (int) Math.pow(2, n);
        t*=t-t/2+0.5;
        System.out.println(t);
    }
}

import java.math.BigInteger;
import java.util.Scanner;

public class CF186C {

    final static BigInteger MOD = BigInteger.valueOf(1000000007);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigInteger n = sc.nextBigInteger();
        long ans = BigInteger.valueOf(4).modPow(n, MOD).add(
                BigInteger.valueOf(2).modPow(n, MOD)).divide(BigInteger.valueOf(2)).mod(
                MOD).longValue();
        System.out.println(ans);
    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;

public class kok {
	static long MOD = 1000000007;

	static long fastPower(long a, long b){
		long res = 1;

		while(b > 0){
			if(b % 2 == 1)
				res = res * a % MOD;
			a = (a * a) % MOD;
			b /= 2;
		}

		return res % MOD;

	}

	public static void main(String[] args) throws IOException {
		FastReader sc = new FastReader(System.in);

		//System.out.println(fastPower(2, 4));

		long year = sc.nextL();

		System.out.println((fastPower(2, year - 1) * (fastPower(2, year) + 1)) % MOD);

  }

}

class FastReader {
	public BufferedReader reader;
    public StringTokenizer tokenizer;

    public FastReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() throws IOException{
        return Integer.parseInt(next());
    }
     public long nextL() throws IOException{
        return Long.parseLong(next());
    }
}

import java.io.*;
import java.math.*;
import java.util.*;

public class SolutionB {

	public static void main(String[] args) {
		new SolutionB().run();
	}
	int mod = 1000000007;
	int [][] mul(int a[][], int b[][]){
		int c[][] = new int[2][2];
		for(int i = 0; i < 2;i++)
			for(int j = 0; j < 2; j++){
				c[i][j] = 0;
				for(int k = 0; k < 2; k++){
					c[i][j] +=(int)( (a[i][k] * 1L * b[k][j]) % mod);
					c[i][j] %= mod;
				}
			}
		return c;
	}
	int [][] pow(int t[][], long n){
		if( n == 0){
			int a[][] = new int[2][2];
			for(int i = 0; i < 2; i++){
				for(int j = 0; j < 2; j++){
					if( i == j) a[i][j] = 1;
					else a[i][j] = 0;
				}
			}
			return a;
		}
		if(n % 2==1) return mul(pow(t, n-1), t);
		int a[][] = pow(t, n/2);
		return mul(a, a);
	}
	void solve() {
		int a[][] = new int[2][2];
		a[0][0] = 3;
		a[1][0] = 1;
		a[0][1] = 1;
		a[1][1] = 0;
		long n = in.nextLong();
		out.println(pow(a, n)[0][0]);
	}

	class Pair implements Comparable<Pair> {
		int x, y;

		Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

		@Override
		public int compareTo(Pair o) {
			if (o.x == x)
				return ((Integer) y).compareTo(o.y);
			return ((Integer) x).compareTo(o.x);
		}

	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner(System.in);
		out = new PrintWriter(new OutputStreamWriter(System.out));
		solve();
		out.close();
	}

	void runIO() {
		try {
			in = new FastScanner(new File("input.txt"));
			out = new PrintWriter(new FileWriter(new File("output.txt")));
			solve();
			out.close();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	class FastScanner {
		BufferedReader bf;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				bf = new BufferedReader(new FileReader(f));
			} catch (IOException ex) {
				ex.printStackTrace();
			}
		}

		public FastScanner(InputStream is) {
			bf = new BufferedReader(new InputStreamReader(is), 32768);
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(bf.readLine());
				} catch (IOException ex) {
					ex.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		float nextFloat() {
			return Float.parseFloat(next());
		}

		String nextLine() {
			try {
				return bf.readLine();
			} catch (Exception ex) {
				ex.printStackTrace();
			}
			return "";
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		BigInteger nextBigInteger() {
			return new BigInteger(next());
		}

		BigDecimal nextBigDecimal() {
			return new BigDecimal(next());
		}

		int[] nextIntArray(int n) {
			int a[] = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = Integer.parseInt(next());
			return a;
		}

		long[] nextLongArray(int n) {
			long a[] = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = Long.parseLong(next());
			return a;
		}
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;

public class C {
	BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer st = null;

	private void solution() throws IOException {
		long n=nextLong();
		long v=binpow(2,n);
		System.out.println(((v)*(v+1))/2 % 1000000007);
	}

	int binpow (int a, long n) {
		if (n == 0)
			return 1;
		if (n % 2 == 1)
			return (binpow (a% 1000000007, n-1% 1000000007)% 1000000007 * a)% 1000000007;
		else {
			int b = binpow (a% 1000000007, n/2% 1000000007)% 1000000007;
			return (b * b)% 1000000007;
		}
	}
	String nextToken() throws IOException {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(bf.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public void print(int a[]) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + " ");
		}
	}

	public static void main(String args[]) throws IOException {
		new C().solution();
	}
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main
{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer tokenizer=null;

	public static void main(String[] args) throws IOException
	{
		new Main().execute();
	}

	void debug(Object...os)
	{
		System.out.println(Arrays.deepToString(os));
	}

	int ni() throws IOException
	{
		return Integer.parseInt(ns());
	}

	long nl() throws IOException
	{
		return Long.parseLong(ns());
	}

	double nd() throws IOException
	{
		return Double.parseDouble(ns());
	}

	String ns() throws IOException
	{
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(br.readLine());
		return tokenizer.nextToken();
	}

	String nline() throws IOException
	{
		tokenizer=null;
		return br.readLine();
	}

	//Main Code starts Here
	int totalCases, testNum;
	long m,n;
	int mod = 1000000007 ;
	void execute() throws IOException
	{
		totalCases = 1;
		for(testNum = 1; testNum <= totalCases; testNum++)
		{
			input();
			solve();
		}
	}

	void solve()
	{
		if(n==0)
			System.out.println(1);
		else if(n==1)
			System.out.println(3);
		else if(n==2)
			System.out.println(10);
		else
		{
			long x = pow(n-2);
			long y = (x*2)%mod;
			long out = (x*(y+1))%mod;
			System.out.println(out);
		}
	}

	long pow(long x)
	{
		//debug(x);
		if(x==0)
			return 1;
		else if(x%2==0)
		{
			long y = pow(x/2);
			long z= y*y;
			if(z<0)
				return z+mod;
			else
				return z;
		}
		else
		{
			long y = pow(x/2);
			long z= ((y*y)%mod)*2;
			if(z<0)
				return z+mod;
			else
				return z;
		}
	}

	void printarr(int [] a,int b)
	{
		for(int i = 0;i<=b;i++)
		{
			if(i==0)
				System.out.print(a[i]);
			else
				System.out.print(" "+a[i]);
		}
		System.out.println();
	}

	boolean input() throws IOException
	{
		n = nl();
		return true;
	}
}

import java.math.BigInteger;
import java.util.Scanner;
public class plant {
    public static void main(String[] args){
         Scanner s=new Scanner(System.in);
       BigInteger e = BigInteger.valueOf(2);
        BigInteger r = BigInteger.valueOf(1000000007);

         BigInteger n = new BigInteger(s.next());
         BigInteger d=e.modPow(n,r );
//        double n=s.nextDouble();
//       double k= Math.pow(2,n);
//       double y=(k/2)*(k+1);
//         double t=0;
//         double y=0;
//         while(t<=k){
//             y+=t;
//             ++t;
//         }

          System.out.println(d.multiply(d.add(new BigInteger("1"))).divide(new BigInteger("2")));

    }
}

import java.util.Scanner;

public class C {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long num = sc.nextLong();

        System.out.println(num * (2 * num + 1));
    }

}

import java.util.Scanner;

public class C_118C {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long [][] a = {{3,1},{1,3}};
		a = pow(a, n);
		System.out.println(a[0][0]);
	}
	public static long [][] pow(long [][] a, long n){
		if(n==1) return a;
		if(n % 2 == 1) {
			 return  multiply(pow(a, n-1),a);
		}else{
			a = pow(a, n/2);
			return multiply(a, a);
		}
	}
	public static long[][] multiply(long[][] a, long[][] b){
		long [][] c = new long[2][2];
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < 2; j++) {
				for (int k = 0; k < 2; k++) {
					c[i][j] += (a[i][k]*b[k][j]) % (double) (1e+9) + 7;
				}
				c[i][j]%=(double) (1e+9) + 7;
			}
		}
		return c;
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        // TODO Auto-generated method stub
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);
        //BufferedReader in = new BufferedReader(new FileReader("input.txt"));
        //PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
        long n=Long.parseLong(in.readLine());
        //double ff=System.currentTimeMillis();
        int mod=1000000007;
        n%=500000003;
        long rem=0;
        if(n==0){
            out.println(1);
        }
        else{
            n--;
            long f=1;
            for(int i=1; i<=n/31; i++){
                f*=32768*65536;
                f%=mod;
            }
            for(int i=1; i<=n%31; i++){
                f*=2;
                f%=mod;
            }
            rem=f*(f*2+1)%mod;
            out.println(rem);
        }

        //out.print(System.currentTimeMillis()-ff);
        out.close();
    }
}

import java.util.Scanner;
public class plant {
    public static void main(String[] args){
         Scanner s=new Scanner(System.in);
         int n=s.nextInt();
         int k=(int) Math.pow(2,n);

         int t=0;
         int y=1;
         while(t!=k){
             y+=t;
             ++t;
         }
         int u=((int)Math.pow(4,n))-y+1;
          System.out.println(u%1000000007);
    }
}

import java.util.*;
import java.io.*;

public class Main {
  public static void main(String[] args) {
Scanner nerd = new Scanner (System.in);
int n = nerd.nextInt();
int up = 1;
int down = 0;

for (int i = 0; i < n; i++)
{
  int newup = up;
  up = up * 3 + down;
  down = down * 3 + newup;
}
if (n == 0)
System.out.println(0);
System.out.println(up);
  }
}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {

    public static long Mod = 10000007;

    public static void main(String[] args) {
        try {
            Scanner in = new Scanner();
            //PrintWriter out = new PrintWriter(new FileOutputStream(new File("output.txt")));
            PrintWriter out = new PrintWriter(System.out);
            long n = in.nextLong();
            long[][] mul = new long[2][2];
            mul[0][0] = 3;
            mul[0][1] = 1;
            mul[1][0] = 1;
            mul[1][1] = 3;
            long[][] pow = powSquareMatrix(mul, n);
            long[][] result = new long[1][2];
            result[0][0] = 1;
            result[0][1] = 0;
            result = mulMatrix(result, pow);
            out.println(result[0][0]);
         //   out.println(cal(n));
            out.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public static long cal(long n){
        long a = 1;
        long b = 0;
        for(int i = 0; i < n; i++){
            long tempA = a;
            a = a*3 + b;
            b = 3*b + tempA;
        }
        return a;
    }

    public static long[][] powSquareMatrix(long[][] A, long p) {
        long[][] unit = new long[A.length][A.length];
        for (int i = 0; i < unit.length; i++) {
            unit[i][i] = 1;
        }
        if (p == 0) {
            return unit;
        }
        long[][] val = powSquareMatrix(A, p / 2);
        if (p % 2 == 0) {
            return mulMatrix(val, val);
        } else {
            return mulMatrix(A, mulMatrix(val, val));
        }

    }

    public static long[][] mulMatrix(long[][] A, long[][] B) {
        long[][] result = new long[A.length][B[0].length];
        for (int i = 0; i < result.length; i++) {
            for (int j = 0; j < result[0].length; j++) {
                for (int k = 0; k < A[0].length; k++) {
                    result[i][j] += (A[i][k] * B[k][j] % Mod);
                    result[i][j] %= Mod;
                }
                result[i][j] %= Mod;
            }
        }

        return result;
    }

    static double dist(Point a, Point b) {
        long total = (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
        return Math.sqrt(total);
    }

    static class Point {

        int x, y;

        public Point(int x, int y) {
            this.x = x;
            this.y = y;

        }
    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    static class FT {

        int[] data;

        FT(int n) {
            data = new int[n];
        }

        void update(int index, int val) {
            // System.out.println("UPDATE INDEX " + index);
            while (index < data.length) {
                data[index] += val;
                index += index & (-index);

                //    System.out.println("NEXT " +index);
            }
        }

        int get(int index) {
            //  System.out.println("GET INDEX " + index);
            int result = 0;
            while (index > 0) {
                result += data[index];
                index -= index & (-index);
                // System.out.println("BACK " + index);
            }
            return result;
        }
    }

    static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        } else {
            return gcd(b, a % b);
        }
    }

    static int pow(int a, int b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        int val = pow(a, b / 2);
        if (b % 2 == 0) {

            return val * val;
        } else {
            return val * val * a;
        }
    }

//    static Point intersect(Point a, Point b, Point c) {
//        double D = cross(a, b);
//        if (D != 0) {
//            return new Point(cross(c, b) / D, cross(a, c) / D);
//        }
//        return null;
//    }
//
//    static Point convert(Point a, double angle) {
//        double x = a.x * cos(angle) - a.y * sin(angle);
//        double y = a.x * sin(angle) + a.y * cos(angle);
//        return new Point(x, y);
//    }
//    static Point minus(Point a, Point b) {
//        return new Point(a.x - b.x, a.y - b.y);
//    }
//
//    static Point add(Point a, Point b) {
//        return new Point(a.x + b.x, a.y + b.y);
//    }
//
//    static double cross(Point a, Point b) {
//        return a.x * b.y - a.y * b.x;
//
//
//    }
//
//    static class Point {
//
//        int x, y;
//
//        Point(int x, int y) {
//            this.x = x;
//            this.y = y;
//        }
//
//        @Override
//        public String toString() {
//            return "Point: " + x + " " + y;
//        }
//    }
    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            //System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //br = new BufferedReader(new FileReader(new File("vans.in")));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}

import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
    static class Reader
    {
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;}
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}if (numChars <= 0) return -1; }return buf[curChar++];}
        public String nextLine(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isEndOfLine(c));return res.toString() ;}
        public String s(){int c = read();while (isSpaceChar(c)) c = read();StringBuilder res = new StringBuilder();do {res.appendCodePoint(c);c = read();}while (!isSpaceChar(c));return res.toString();}
        public long l(){int c = read();while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }long res = 0; do{ if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read();}while(!isSpaceChar(c));return res * sgn;}
        public int i(){int c = read() ;while (isSpaceChar(c)) c = read();int sgn = 1;if (c == '-') { sgn = -1 ; c = read() ; }int res = 0;do{if (c < '0' || c > '9') throw new InputMismatchException();res *= 10 ; res += c - '0' ; c = read() ;}while(!isSpaceChar(c));return res * sgn;}
        public double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; }
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; }
        public int[] arr(int n){int[] ret = new int[n];for (int i = 0; i < n; i++) {ret[i] = i();}return ret;}
    }

           //       |----|       /\      |    |   -----   |
           //       |   /       /  \     |    |     |     |
           //       |--/       /----\    |----|     |     |
           //       |   \     /      \   |    |     |     |
           //       |    \   /        \  |    |   -----   -------

    static int n,m;
    static long power(long x,long y,long p)
    {
        long res = 1;
        x = x % p;
        while (y > 0)
        {
            if((y & 1)==1)
                res = (res * x) % p;
            y = y >> 1;
            x = (x * x) % p;
        }
        return res;
    }
    public static void main(String[] args)throws IOException
    {
        PrintWriter out= new PrintWriter(System.out);
        Reader sc=new Reader();
        //OEIS ZINDABAD
        long n=sc.l();
        long p1=power(2,n-1,1000000007l);
        long p2=power(2,n,1000000007l);
        out.println((p1*(1+p2))%1000000007);
        out.flush();
    }
}

import java.io.*;
import java.util.*;

public class A implements Runnable {
    private MyScanner in;
    private PrintWriter out;

    final long MOD = 1000000007;

    long mod(long n) {
        return (n % MOD + MOD) % MOD;
    }

    long pow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        long ans = pow(a, b / 2);
        ans = (ans * ans) % MOD;
        if (b % 2 == 1) {
            ans = (ans * a) % MOD;
        }
        return ans;
    }

    private void solve() {
        long n = in.nextLong();
        long overall = pow(4, n);
        long more = pow(2, n);
        out.println(mod((overall + more) / 2));
    }

    @Override
    public void run() {
        in = new MyScanner();
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

    public static void main(String[] args) {
        new A().run();
    }

    class MyScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public void close() {
            try {
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        public boolean hasNext() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String s = br.readLine();
                    if (s == null) {
                        return false;
                    }
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    return false;
                }
            }
            return st != null && st.hasMoreTokens();
        }

        private String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String s = br.readLine();
                    if (s == null) {
                        return null;
                    }
                    st = new StringTokenizer(s);
                } catch (IOException e) {
                    e.printStackTrace();
                    return null;
                }
            }
            return st.nextToken();
        }

        public String nextLine() {
            try {
                st = null;
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

import java.io.*;
import java.util.*;
import java.math.*;

public class Main
{
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	StringTokenizer tokenizer=null;

	public static void main(String[] args) throws IOException
	{
		new Main().execute();
	}

	void debug(Object...os)
	{
		System.out.println(Arrays.deepToString(os));
	}

	int ni() throws IOException
	{
		return Integer.parseInt(ns());
	}

	long nl() throws IOException
	{
		return Long.parseLong(ns());
	}

	double nd() throws IOException
	{
		return Double.parseDouble(ns());
	}

	String ns() throws IOException
	{
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(br.readLine());
		return tokenizer.nextToken();
	}

	String nline() throws IOException
	{
		tokenizer=null;
		return br.readLine();
	}

	//Main Code starts Here
	int totalCases, testNum;
	long m,n;
	int mod = 1000000007 ;
	void execute() throws IOException
	{
		totalCases = 1;
		for(testNum = 1; testNum <= totalCases; testNum++)
		{
			input();
			solve();
		}
	}

	void solve()
	{
		if(n==0)
			System.out.println(1);
		else if(n==1)
			System.out.println(3);
		else if(n==2)
			System.out.println(10);
		else
		{
			long x = pow(n-1);
			long y = (x*2)%mod;
			long out = (x*(y+1))%mod;
			System.out.println(out);
		}
	}

	long pow(long x)
	{
		//debug(x);
		if(x==0)
			return 1;
		else if(x%2==0)
		{
			long y = pow(x/2);
			long z= y*y;
			if(z<0)
				return z+mod;
			else
				return z;
		}
		else
		{
			long y = pow(x/2);
			long z= ((y*y)%mod)*2;
			if(z<0)
				return z+mod;
			else
				return z;
		}
	}

	void printarr(int [] a,int b)
	{
		for(int i = 0;i<=b;i++)
		{
			if(i==0)
				System.out.print(a[i]);
			else
				System.out.print(" "+a[i]);
		}
		System.out.println();
	}

	boolean input() throws IOException
	{
		n = nl();
		return true;
	}
}

import java.util.Scanner;

public class CF185A {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();

        double up = (double)(Math.pow(4,n) - Math.pow(2,n)) / 2 + Math.pow(2,n);

        int r = (int)up % 1000000007;

        System.out.println(r);

    }

}

import java.io.*;
import java.text.*;
import java.util.*;
import java.math.*;
public class C {
	public static void main(String[] args) throws Exception {
		new C().run();
	}
	public void run() throws Exception {
		FastScanner f = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		long val = f.nextLong();
		if(val == 0) {
			System.out.println(1);
			return;
		}
		int up = 1, down = 0;
		int b = 1;
		while(b <= val) b <<= 1;
		b >>= 1;
		for(; b > 0; b >>= 1) {
			int temp = up;
			up = up*up+down*down;
			down = 2*temp*down;
			if((val & b) != 0) {
				temp = up;
				up = 3*temp+down;
				down = 3*down+temp;
			}
			up %= 1000_000007;
			down %= 1000_000007;
		}
		out.println(up);
		out.flush();
	}
    static class FastScanner {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        public FastScanner() {
            reader = new BufferedReader(new InputStreamReader(System.in), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
        	return Long.parseLong(next());
        }
        public double nextDouble() {
        	return Double.parseDouble(next());
        }
        public String nextLine() {
        	try {
        		return reader.readLine();
        	} catch(IOException e) {
        		throw new RuntimeException(e);
        	}
        }

    }
}

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

    public class Test {
            public static void main(String args[]){
            	Scanner input = new Scanner(System.in);
                   	String s = input.nextLine();
                    maximum(s);
            }

          public static void maximum(String s){
        	  BigInteger a = new BigInteger(s);
        	  BigInteger b = new BigInteger("2");
        	  BigInteger mode = new BigInteger("1000000007");
        	  BigInteger d = new BigInteger("1");
        	  BigInteger c = b.modPow(a,mode);
        	  System.out.println((c.multiply(c.add(d))).divide(b));

            	  //1000000007
          }
    }

import java.util.Scanner;

public class Plant {
	static int MOD = 1000000007;

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long n = scan.nextInt();

		long x = po(2,n-1);
		System.out.println((long)(2 * Math.pow(x, 2) % MOD  + x) % MOD);

	}

	static long po(long b, long p) {
	    p %= (MOD-1);
	    if (p == 0)
	    	return 1;

	    return po(b * b % MOD, p / 2) * ( (p & 1) == 1 ? b : 1 ) % MOD;
	}

}

import java.util.*;
import java.io.*;
import java.math.*;

public class c {

	public static void main(String agrs[])throws Exception{
		Scanner in=new Scanner(System.in);
		long n = in.nextLong();
		long p = (long)1e9 + 7;
		/*
		long four = powerMod(4, n, ((long)1e9) + 7);
		long two = powerMod(2, n, ((long)1e9) + 7);
		System.out.println(four + " " +  (power(2, n))+ " " + two + " " + (((two/2)*(two-1)) + " " + (powerMod(2, 2*n, (long)(1e9 + 7)) - powerMod(2, n, p))/2));
		*/
		/*
		BigInteger fbig = power(BigInteger.valueOf(2), n);
		System.out.println("adsf");
		BigInteger tbig2 = fbig;
		fbig = fbig.multiply(fbig);
		BigInteger tbig1 = fbig;
		System.out.println((fbig.subtract((tbig1.subtract(tbig2)).divide(BigInteger.valueOf(2)))).mod(BigInteger.valueOf(p)));
		*/
		long fbig = powerMod(2, n, p);
		//long tbig2 = powerMod(2, n, p);
		//fbig = (fbig*fbig)%p;
		//long tbig1 = fbig;
		if (n == 0) System.out.println(1);
		else
		System.out.println(((fbig + 1)*(fbig/2))%p);

	}

	static long gcd(long a, long b) { return (b == 0 ? a : gcd(b, a % b)); }
	static long lcm(long a, long b) { return (a*b) / gcd(a, b); }

	static long power(long a, long b){
		if (b == 0) return 1;
		if (b % 2 == 1) return power(a, b-1)*b;
		else { long t = power(a, b/2); return t*t; }
	}

	static BigInteger power(BigInteger a, long b){
		if (b == 0) return BigInteger.ONE;
		if (b % 2 == 1) return power(a, b-1).multiply(a);
		else { BigInteger t = power(a, b/2); return t.multiply(t); }
	}

	static long powerMod(long a, long b, long p){
		if (b == 0) return 1;
		if (b % 2 == 1) return (powerMod(a, b-1, p)*a)%p;
		else { long t = powerMod(a, b/2, p); return (t*t)%p;}
	}

	static class point implements Comparable<point>{

		int x, y, id;

		public point(int x, int y, int id){
			this.x = x; this.y = y; this.id =id;
		}

		public int compareTo(point o) {
			if (this.x == o.x) return this.y - o.y;
			return this.x - o.x;
		}

	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    static long mod=1000000007;
    public static long pow(long n)
    {
        if(n==0)
            return 1;
        long t=pow(n/2);
        t=(t*t)%mod;
        if(n%2==1)
            t=(t*2)%mod;
        return t;
    }
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        long n=Long.parseLong(br.readLine());
        n=pow(n);
        n%=mod;
        n*=n+1;
        n%=mod;
        n/=2;
        System.out.print(n);
    }
}

import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main{
    public static int MOD = 1000000007;
    public static void main(String args[])throws Exception{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine().trim();
        long n = Long.parseLong(s);
        long a = binPow(2,2*n-1);
        long b = binPow(2,n-1);
        if(n==0)System.out.println(0);
        else
        System.out.println(a+b);
    }
    public static long binPow(int n,long pow){
        if(pow==0)return 1;
        if(pow==1)return n;
        if(pow%2==0){
            long v = binPow(n, pow/2)%MOD;
            return (v*v)%MOD;
        }
        else{
            long v = binPow(n, pow/2)%MOD;
            return (v*v*n)%MOD;
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Plant {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        long year = Long.parseLong(reader.readLine());
        if (year == 0) {
            System.out.println(1);
        } else {
            System.out.println(((year * 2) * ((year * 2) + 1)) / 2);
        }
        reader.close();
    }
}

import java.util.Scanner;

public class ProblemC {

    private static final int m = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int a = 1;
        int c = 2;
        while (n > 0) {
            if (n % 2 == 1) {
                a = (a * c) % m;
            }
            c = (c * c) % m;
            n /= 2;
        }
        System.out.println((int) (a * (a - a / 2 + 0.5)));
    }
}

import java.io.*;
import java.util.*;

/*
 * kishan Thesiya
 * daiict
 * kishanthesiya25@gmail.com
 *
 *
 */

public class Main {
	FastScanner in;
	PrintWriter out;

	static ArrayList[] adj;
	static int n;
	static int x;
	static int visited[];
	static int Ad[];
	static int Bd[];

	class Item implements Comparable<Item> {
		int num;
		int val;

		public Item(int num, int val) {
			super();
			this.num = num;
			this.val = val;
		}

		@Override
		public int compareTo(Item arg0) {
			return Integer.compare(val, arg0.val);
		}
	}

    void solve() {

    	long n = in.nextLong();
    	long mod = (long)1e9+7;

    	long i = pow(2,n,mod);
    	long j = pow(4,n,mod);

    	long ans = (i+j)%mod;
    	ans = (ans/2)%mod;

    	out.print(ans);

    }

	public static long gcd(long x, long y) {
		if (x == 0)
			return y;
		else
			return gcd( y % x,x);
	}
	public static long pow(long n,long p,long m){
        long  result = 1;
         if(p==0)
           return 1;
       if (p==1)
           return n;
       while(p!=0)
       {
           if(p%2==1)
               result *= n;
           if(result>=m)
           result%=m;
           p >>=1;
           n*=n;
           if(n>=m)
           n%=m;
       }
       return result;
       }

	public static boolean isPrime(int n) {
		// Corner cases
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;

		// This is checked so that we can skip
		// middle five numbers in below loop
		if (n % 2 == 0 || n % 3 == 0)
			return false;

		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(in.br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	class Tri{

		Tri[] arr;

		public Tri(){
			arr = new Tri[27];
		}

	}

	public static void main(String[] args) {
		new Main().run();
	}
}

import java.util.Scanner;
import java.math.BigInteger;
public class plant
{
 public static void main(String args[])
 {
   int n;
   Scanner in=new Scanner(System.in);
   n=in.nextInt();
   power(n);
 }
 public static void power(int n1)
 {
  int i=1;
   BigInteger mod1=new BigInteger("10000000007");
   BigInteger b=new BigInteger("2");
   BigInteger n2=BigInteger.valueOf(n1);
   BigInteger j=BigInteger.valueOf(i);
   BigInteger f=BigInteger.ONE;
   BigInteger f1=new  BigInteger("4");
   BigInteger f2=new BigInteger("2");
   BigInteger v1=BigInteger.valueOf((long)(Math.pow(4,n1)));
   BigInteger v2=BigInteger.valueOf((long)(Math.pow(2,n1)));
   BigInteger sum=v1.add(v2);
   BigInteger div=sum.divide(b);
   BigInteger res=div.mod(mod1);
   System.out.println(res);
}
}

import java.math.BigInteger;
import java.util.Scanner;

public class CF186C {

    final static BigInteger MOD = BigInteger.valueOf(1000000007);

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigInteger n = sc.nextBigInteger();
        long ans = BigInteger.valueOf(4).modPow(n, MOD).add(
                BigInteger.valueOf(2).modPow(n, MOD)).divide(BigInteger.valueOf(2)).mod(
                MOD).longValue();
        System.out.println(ans);
    }

}

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

import static java.lang.Math.log;
import static java.lang.Math.max;
import static java.lang.Math.pow;

public class CF186C {
    static public void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                CF186C.run();
            }
        }, "1", 16 * (1 << 20)).start();
    }

    static void run() {
        Scanner scanner = new Scanner(System.in);
        try {
            long n = scanner.nextLong();
            long res = (pow2(n * 2 - 1) + pow2(n - 1)) % 1000000007;
            System.out.println(res);
        }

        finally {
            scanner.close();
        }
    }

    static long[] d = new long[128]; // d[i] is 2 ^ (2 ^ i)
    static {
        d[0] = 2;
        for (int i = 1; i < d.length; i++)
            d[i] = (d[i - 1] * d[i - 1]) % 1000000007;
    }

    static long pow2(long p) {
        if (p <= 60) {
            return 1 << p;
        }
        int log2 = (int)(log(p)/log(2));
        return (d[log2] * pow2(p - 1 << log2)) % 1000000007;
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.StringTokenizer;

public class kok {
	static long MOD = 1000000007;

	static long fastPower(long a, long b){
		long res = 1;

		while(b > 0){
			if(b % 2 == 1)
				res = res * a % MOD;
			a = (a * a) % MOD;
			b /= 2;
		}

		return res % MOD;

	}

	public static void main(String[] args) throws IOException {
		FastReader sc = new FastReader(System.in);

		//System.out.println(fastPower(2, 4));

		long year = sc.nextL();

		System.out.println((fastPower(2, year - 1) + fastPower(2, year)) % MOD);

  }

}

class FastReader {
	public BufferedReader reader;
    public StringTokenizer tokenizer;

    public FastReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() throws IOException{
        return Integer.parseInt(next());
    }
     public long nextL() throws IOException{
        return Long.parseLong(next());
    }
}

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNextLong()) {
			long a=sc.nextLong();
			System.out.println(((long)Math.pow(2, 2*a-1)+Math.pow(2, a-1)));
		}
	}
}

import java.math.BigInteger;
import java.util.Scanner;

public class C {

	public static void main(String[] args) throws Exception {
		Scanner in = new Scanner(System.in);
		long n = in.nextLong()*2;
		System.out.println(((BigInteger.valueOf(n).multiply(BigInteger.valueOf(n+1)).divide(BigInteger.valueOf(2)))).mod(BigInteger.valueOf(1000000007)));
	}
}

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;

    public class Test {
            public static void main(String args[]){
            	Scanner input = new Scanner(System.in);
                   	String s = input.nextLine();
                    maximum(s);
            }

          public static void maximum(String s){
        	  BigInteger a = new BigInteger(s);
        	  BigInteger b = new BigInteger("2");
        	  BigInteger mode = new BigInteger("1000000007");
        	  BigInteger d = new BigInteger("1");
        	  //BigInteger c = b.modPow(a,mode);
        	  BigInteger cs = b.modPow(a,mode);
        	  //System.out.println((c.multiply(c.add(d))).divide(b));
        	  if(cs.multiply(cs.add(d)).compareTo(d) <= 0){
            	  System.out.println(cs.multiply(cs.add(d)));
        	  }else{
        		  System.out.println(cs.multiply(cs.add(d)).divide(b));
        	  }

            	  //1000000007
          }

    }

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Plant
{
	static final int MOD = 1000000007;

	static long[][] multi(long[][] a, long[][] b)
	{
		long[][] r = new long[2][2];
		r[0][0] = ((a[0][0] % MOD) * (b[0][0] % MOD) + (a[0][1] % MOD)
				* (b[1][0] % MOD)) % MOD;
		r[0][1] = ((a[0][0] % MOD) * (b[0][1] % MOD) + (a[0][1] % MOD)
				* (b[1][1] % MOD)) % MOD;
		r[1][0] = ((a[1][0] % MOD) * (b[0][0] % MOD) + (a[1][1] % MOD)
				* (b[1][0] % MOD)) % MOD;
		r[1][1] = ((a[1][0] % MOD) * (b[0][1] % MOD) + (a[1][1] % MOD)
				* (b[1][1] % MOD)) % MOD;
		return r;
	}

	public static void main(String[] args) throws Exception
	{
		long n = readLong();
		long[][] t = { { 3, 1 }, { 1, 3 } };
		long[][] m = t;

		for (int i = 1; i < 64; i++)
		{
			if ((1l << i & n) != 0)
				t = multi(t, m);
			m = multi(m, m);
		}

		System.out.println(t[0][0]);
	}

	static BufferedReader br = new BufferedReader(new InputStreamReader(
			System.in));
	static PrintWriter out = new PrintWriter(new BufferedWriter(
			new OutputStreamWriter(System.out)));
	static StringTokenizer st;

	static String next() throws IOException
	{
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}

	static long readLong() throws IOException
	{
		return Long.parseLong(next());
	}

	static int readInt() throws IOException
	{
		return Integer.parseInt(next());
	}

	static double readDouble() throws IOException
	{
		return Double.parseDouble(next());
	}

	static char readChar() throws IOException
	{
		return next().charAt(0);
	}

	static String readLine() throws IOException
	{
		return br.readLine().trim();
	}
}

import java.util.Scanner;
public class Triangle1
{
 public static void main(String args[])

 {
  long n;
  Scanner in=new Scanner(System.in);
  n=in.nextLong();
  long n1=(long)(Math.pow(4,n));
  long n2=(long)(Math.pow(2,n));
  long tri=(n1+n2)/2;
  System.out.println(tri);
 }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws NumberFormatException, IOException {
        // TODO Auto-generated method stub
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out=new PrintWriter(System.out);
        //BufferedReader in = new BufferedReader(new FileReader("input.txt"));
        //PrintWriter out = new PrintWriter(new FileWriter("output.txt"));
        long n=Long.parseLong(in.readLine());
        //double ff=System.currentTimeMillis();
        int mod=1000000007;
        n%=500000003;
        long rem=0;
        if(n==0){
            out.println(1);
        }
        else{
            n--;
            long f=1;
            for(int i=1; i<=n/31; i++){
                f*=32768*65536;
                f%=mod;
            }
            for(int i=1; i<=n%31; i++){
                f*=2;
                f%=mod;
            }
            rem=f*(f*2+1)%mod;
            out.println(rem);
        }

        //out.print(System.currentTimeMillis()-ff);
        out.close();
    }
}

import java.util.Scanner;
public class plant {
    public static void main(String[] args){
         Scanner s=new Scanner(System.in);
         int n=s.nextInt();
         int k=(int) Math.pow(2,n);

         int t=0;
         int y=1;
         while(t!=k){
             y+=t;
             ++t;
         }
         int u=((int)Math.pow(4,n))-y+1;
          System.out.println(u%1000000007);
    }
}

import java.util.Scanner;

public class C {
	public static void main(String[] args) {
		Scanner theIn=new Scanner(System.in);

	}
}

import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main{
    public static int MOD = 1000000007;
    public static void main(String args[])throws Exception{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine().trim();
        long n = Long.parseLong(s);
        long a = binPow(2,2*n-1);
        long b = binPow(2,n-1);
        if(n==0)System.out.println(0);
        else
        System.out.println(a+b);
    }
    public static long binPow(int n,long pow){
        if(pow==0)return 1;
        if(pow==1)return n;
        if(pow%2==0){
            long v = binPow(n, pow/2)%MOD;
            return (v*v)%MOD;
        }
        else{
            long v = binPow(n, pow/2)%MOD;
            return (v*v*n)%MOD;
        }
    }
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Locale;
import java.util.StringTokenizer;

public class A {

	private long pow(long a, long p, long mod) {
		if (p == 0) {
			return 1;
		} else if (p % 2 == 0) {
			return pow((a * a) % mod, p / 2, mod);
		} else {
			return (pow(a, p - 1, mod) * a) % mod;
		}
	}

	private void solve() throws IOException {
		long n = nextLong();
		long mod = (long)(1e9 + 7.0001);

		long p = pow(2, n, mod);
		println(((1 + p) * p / 2) % p);
	}

	private String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	private int nextInt() throws NumberFormatException, IOException {
		return Integer.parseInt(nextToken());
	}

	private double nextDouble() throws NumberFormatException, IOException {
		return Double.parseDouble(nextToken());
	}

	private long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private void print(Object o) {
		writer.print(o);
	}

	private void println(Object o) {
		writer.println(o);
	}

	private void printf(String format, Object... o) {
		writer.printf(format, o);
	}

	public static void main(String[] args) {
		long time = System.currentTimeMillis();
		Locale.setDefault(Locale.US);
		new A().run();
		System.err.printf("%.3f\n", 1e-3 * (System.currentTimeMillis() - time));
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	private void run() {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(13);
		}
	}
}