#include"stdio.h" #include"string.h" #include"stdlib.h" int main() { int n; int f[10011],a[10011],b[10011]; int i; a[1]=b[1]=1; a[2]=b[2]=2; f[1]=2; f[2]=4; for(i=3;i<=10000;i++) { a[i]=f[i-1]; b[i]=(b[i-1]+a[i-2])%9997; f[i]=(a[i]+b[i])%9997; } while(scanf("%d",&n),n!=-1) printf("%d\n",f[n]); return 0; }