#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int n,k;
int a[4005][4005],b[4005][4005];int c[4005][4005],t[4005][4005];
void mu(int a[][4005],int b[][4005],int n){
memset(c,0,sizeof c);
for(int i=1;i<=2*n;i++){
for(int j=1;j<=2*n;j++){
for(int k=1;k<=2*n;k++){
c[i][j]+=a[i][k]*b[k][j];
c[i][j]%=1000;
}
}
}
for(int i=1;i<=2*n;i++){
for(int j=1;j<=2*n;j++){
a[i][j]=c[i][j];
//printf("%d ",a[i][j]);
}
//printf("\n");
}
return;
}
void answer(int a[][4005],int k){
while(k){
if(n&1) mu(a,
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int n,k;
int a[4005][4005],b[4005][4005];int c[4005][4005],t[4005][4005];
void mu(int a[][4005],int b[][4005],int n){
memset(c,0,sizeof c);
for(int i=1;i<=2*n;i++){
for(int j=1;j<=2*n;j++){
for(int k=1;k<=2*n;k++){
c[i][j]+=a[i][k]*b[k][j];
c[i][j]%=1000;
}
}
}
for(int i=1;i<=2*n;i++){
for(int j=1;j<=2*n;j++){
a[i][j]=c[i][j];
//printf("%d ",a[i][j]);
}
//printf("\n");
}
return;
}
void answer(int a[][4005],int k){
while(k){
if(n&1) mu(a,