//枚举每个相遇点求最小值
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;
const int N = 40010,M=2*N;
int te,fe,s;
int t,f,n,m;
int h[N],e[M],ne[M],idx;
int dist1[N];//以空间换时间,先预处理到数组中
int dist2[N];//如果只用一个数组会TLE
int dist3[N];
void add(int a,int b)
{
e[idx]=b,ne[idx]=h[a],h[a]=idx++;
}
void bfs(int st,int dist[])
{
for(int i=1;i<=n;i++) dist[i]=0x3f3f3f3f;
queue<int>q;
q.push(st);
dist[st]=0;
while(q.size())
{
int t=q.front();
q.pop();
for(int i=h[t];i!=-1;i=ne[i])
{
int j=e[i];
if(dist[j]!=0x3f3f3f3f) continue;
dist[j]=dist[t]+1;
q.push(j);
}
}
}
signed main()
{
std::ios::sync_with_stdio(false);
std::cin.tie(NULL);
scanf("%d%d%d",&te,&fe,&s);
scanf("%d%d%d%d",&t,&f,&n,&m);
memset(h,-1,sizeof h);
int a,b;
while(m--)
{
scanf("%d%d",&a,&b);
add(a,b),add(b,a);
}
bfs(n,dist1);
if(dist1[t]==0x3f3f3f3f||dist1[f]==0x3f3f3f3f)
{
puts("-1");
return 0;
}
int res=0x3f3f3f3f;
bfs(t,dist2);
bfs(f,dist3);
for(int i=1;i<=n;i++)
{
int s1=te+fe-s;
int a=dist1[i];
int b=dist2[i];
int c=dist3[i];
res=min(res,a*s1+b*te+c*fe);
}
if(res==0x3f3f3f3f) puts("-1");
else printf("%d",res);
return 0;
}