https://vjudge.net/contest/278754#problem/G
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
ll x,y,n,m,c,l,a,b,d,k,p,t;
ll exgcd(ll a,ll b,ll &x,ll &y){
ll ans;
if (b==0){
x=1;y=0;return a;
}
ans=exgcd(b,a%b,y,x);
y=y-(a/b)*x;
return ans;
}
int main(){
scanf("%lld%lld%lld%lld%lld",&x,&y,&m,&n,&l);
a=n-m;
c=x-y;
b=l;
if (a<0){
a=-a;
c=-c;
}
p=exgcd(a,b,x,y);
if (c%p) printf("Impossible\n");else{
x=x*c/p;
t=b/p;
printf("%lld\n",(x%t+t)%t);
}
}