I am getting wrong answer in http://www.spoj.com/problems/FIBFUNCH/ Please somebody help.
include<stdio.h>
int main() { long long int t,n,x,y,s=0,m,i=0; scanf("%lld",&t); while(t--) {s=0; scanf("%lld%lld%lld%lld",&x,&y,&n,&m); s=(x%m+y%m)%m; for(i=2;i<n;i++) { y=x+y; x=y-x; s+=(y%m); s%=m; } printf("%lld\n",s); } return 0; }