#include using namespace std; int B[2],C[2]; main() { for(int i=0;i<2;i++)cin>>C[i]>>B[i],B[i]=(B[i]%C[i]+C[i])%C[i]; for(int n=0;n