#include <bits/stdc++.h>
#define int long long
#define rint register int
#define up(v,s,t,st) for(rint v=s;v<=t;v+=st)
#define down(v,s,t,st) for(rint v=s;v<t;v+=st)
#define ite(v, cont) for(const auto& v:cont)
#define aite(v, cont) for(auto &v:cont)
#define sp(t) !(t&(t-1))
const int mod = 1e9+7;
using namespace std;
void exgcd(int a, int b, int& x, int& y)
{
if(b==0)
{
x=1;
y=0;
return ;
}
int tx, ty;
exgcd(b, a%b, tx, ty);
x=ty;
y=tx-a/b*ty;
}
signed main()
{
int x,y,m,n,L;
cin>>x>>y>>m>>n>>L;
int t,a;
int g = __gcd(n-m, L);
if((x-y)%g!=0)
{
cout<<"Impossible\n";
return 0;
}
exgcd(L, n-m, t, a);
int p = (x-y)/g;
t*=p, a*=p;
if(a<0)
{
int w = ceil((double)(-a)/L);
a=a+w*L;
cout<<a;
}
else if(a>=0)
{
int w = a/L;
a=a-w*L;
cout<<a;
}
}
谢谢大佬🙏