import numpy as np
n=10**18
m=10**9
a=np.zeros((9,9),dtype=np.int64)
a[0]=[4,-5,4,-7,6,0,2,-5,2]
for i in range(1,9):
a[i][i-1]=1
r=np.identity(9,dtype=np.int64)
print(r)
k=n-1
while k>0:
if k & 1:
r=np.dot(a,r)%m
k//=2
a=np.dot(a,a)%m
print(np.dot(r[-1],np.array([236,108,47,19,7,2,0,0,0]))%m)