L. Swimmer
#include<bits/stdc++.h>
using namespace std;
long long a[1000001];
int main(){
int n,q,i,j;
long long m,x,z,y;
scanf("%d %lld %d",&n,&m,&q);
for(i=1;i<=n;i++){
scanf("%lld",&a[i]);
}
while(q--){
scanf("%lld %d",&x,&y);
z=m*2;
y=a[y]*x;
y=y%z;
if(y>m)printf("%lld\n",z-y);
else printf("%lld\n",y);
}
return 0;
}