import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); sc.close(); int mod = 1000000007; int k = 6; long[][][] c = new long[61][k][k]; for (int i = 0, j = 1; i < k; i++, j *= 6) { c[0][0][i] = j; } for (int i = 1; i < k; i++) { c[0][i][i - 1] = 1; } for (int i = 0; i < c.length - 1; i++) { for (int j = 0; j < k; j++) { for (int j2 = 0; j2 < k; j2++) { for (int x = 0; x < k; x++) { c[i + 1][j][j2] += c[i][j][x] * c[i][x][j2]; c[i + 1][j][j2] %= mod; } } } } long ans = 0; long[] a = {2401, 343, 49, 7, 1, 1}; if (n < 6) { ans = a[(int) (5 - n)]; } else { for (int i = 0; i < c.length; i++) { if ((n >> i & 1) == 1) { long[] tmp = new long[k]; for (int j = 0; j < k; j++) { for (int x = 0; x < k; x++) { tmp[j] += c[i][j][x] * a[x]; tmp[j] %= mod; } } a = tmp; } } ans = a[5]; } long div = power(6, n, mod); ans = ans * modinv(div, mod) % mod; System.out.println(ans); } static long power(long x, long n, int m) { if (n == 0) { return 1; } long val = power(x, n / 2, m); val = val * val % m; if (n % 2 == 1) { val = val * x % m; } return val; } static long modinv(long a, int m) { long b = m; long u = 1; long v = 0; long tmp = 0; while (b > 0) { long t = a / b; a -= t * b; tmp = a; a = b; b = tmp; u -= t * v; tmp = u; u = v; v = tmp; } u %= m; if (u < 0) u += m; return u; } }