import java.util.Scanner; public class Main { static long mod = (long)(Math.pow(10, 9)) + 7; public static void main(String[] args) { Scanner sc = new Scanner(System.in); long N = sc.nextLong(); sc.close(); long t = N - 1; long[][] A = {{10, 3}, {0, 1}}; long[][] B = {{1, 0}, {0, 1}}; while(t > 0) { if(t % 2 == 1) { B = mul(B, A); } t /= 2; A = mul(A, A); mod(A); mod(B); } long a = 13 * B[0][0] + B[0][1]; System.out.println(a % mod); } static void mod(long[][] A){ for(int i = 0; i < 2; i++) { for(int j = 0; j < 2; j++) { A[i][j] %= mod; } } } static long[][] mul(long[][] A, long[][] B){ long[][] ret = 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++) { ret[i][j] += A[i][k] * B[k][j]; } } } return ret; } }