You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly.

<image>

An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he makes a step from one vertex to another one along some edge of the tetrahedron. The ant just can't stand on one place.

You do not have to do much to solve the problem: your task is to count the number of ways in which the ant can go from the initial vertex D to itself in exactly n steps. In other words, you are asked to find out the number of different cyclic paths with the length of n from vertex D to itself. As the number can be quite large, you should print it modulo 1000000007 (109 + 7). 

Input

The first line contains the only integer n (1 ≤ n ≤ 107) — the required length of the cyclic path.

Output

Print the only integer — the required number of ways modulo 1000000007 (109 + 7).

Examples

Input

2


Output

3


Input

4


Output

21

Note

The required paths in the first sample are: 

  * D - A - D
  * D - B - D
  * D - C - D

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

public class Tetrahedron 
{
	private static long[][] modularMatricesMultiplication(long[][] first, long[][] second,long mod)
	{
		// ( rows1 x cols1 ) * (rows2 x cols2) = (rows1 x cols2) , cols1=rows2
		// nxm * mxk = nxk 
		long result[][] = new long[first.length][second[0].length];
		for (int row = 0; row < first.length; row++) 
		{
			for (int col = 0; col < second[0].length; col++) 
			{
				for (int item = 0; item < second.length; item++) 
				{
					result[row][col]= result[row][col]+(first[row][item]%mod * second[item][col]%mod)%mod;
				}
			}
		}
		return result;
	}
	
	//fast exponentiation
	private static long[][] modularMatrixExponetiation(long[][] matrix,long power,long mod)
	{
		long result[][] = new long[matrix.length][matrix[0].length];
		boolean firstTime = true;
		while(power!=0)
		{
			//odd
			if((power&1)==1)
			{
				/*
				 * For even and odd powers you will square (satisfied in line 41)
				 * But in case of odd power, you need to multiply by the matrix again
				 * ex. a^3 = a^2 * a 
				 * so we use result here to do this multiplication
				 * Also, in the first time we only need to make result = matrix, but for the next
				 * times we need to multiply it.
				 */
				if(firstTime)
				{
					result = matrix;
					firstTime=false;
				}
				else	result = modularMatricesMultiplication(matrix,result,mod);
			}
			power/=2;
			matrix = modularMatricesMultiplication(matrix,matrix,mod);
		}
		return result;
	}
	
	
		public static void main(String[] args) 
		{
			BufferedTokenizer io = new BufferedTokenizer(System.in);
			int n = io.nextInt();
			
			if(n==1) io.println("0");
			else if(n==2) io.println("3");
			else
			{
				long transformationMatrix[][] = new long[2][2];
				transformationMatrix[0][0] = 2;
				transformationMatrix[0][1] = 3;
				transformationMatrix[1][0] = 1;
				transformationMatrix[1][1] = 0;
				
				transformationMatrix = modularMatrixExponetiation(transformationMatrix,n-2,1000000007);
				long f[] = {3,0};
				
				long result=0;
				for (int item = 0; item < 2; item++) 
				{
					result+= (transformationMatrix[0][item]%1000000007 * f[item]%1000000007)%1000000007;
				}
				io.println((result%1000000007)+"");
				
			}
		}
		
		 public static class BufferedTokenizer 
		 {
		        private BufferedReader reader;
		        private StringTokenizer tokenizer;
		        private PrintWriter writer;
		 
		        public BufferedTokenizer(InputStream stream) 
		        {
		            reader = new BufferedReader(new InputStreamReader(stream));
		            writer = new PrintWriter(System.out);
		            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 void println(String x)
		        {
		        	writer.println(x);
		        	writer.flush();
		        }
		    }
}
