{
TASK: NYKSTUKAIV
LANG: PASCAL
}
program nykstukaiv;
  const PRF = 'NAMAS.DAT';
        RZF = 'NAMAS.REZ';
        MXK = 50; { maksimalus kambariø skaièius aukðte }
        MXA = 50; { maksimalus aukðtø skaièius pernumeravimui }
        MAX = 50*50; { kamb*aukðtai }
  type Tvmas = array [0..2500] of longint;
       Tlmas = array [0..MAX, 0..MAX] of boolean;

  var Q: Tvmas; { eile }
      d, tv, nyk: Tvmas; { ieðkomi atstumai ir "tëvai" ir nykðtukø kamb. }
      K: longint; { kambariø skaièius name }
      t, t1, t2: longint; { laiko limitai }
      G: Tlmas; { grafas, durys }
      NS: longint; { nykðtukø skaièius }

procedure i_eile (x: longint; var uodega: longint);
begin
  Q[uodega] := x;
  uodega := uodega + 1;
end; { i_eile }

procedure is_eiles (var x, uodega: longint);
  { paðalinamas elementas, kurio numeris x }
begin
  uodega := uodega - 1;
  Q[x] := Q[uodega];
end; { is_eiles }

procedure Inicializuoti (s: longint; var G: Tlmas);
  var v: longint;
begin
  for v := 0 to K do
    begin
       d[v] := maxlongint;
       tv[v] := 0;
    end;
  d[s] := t1;
end; { Inicializuoti }

function min (uodega: longint): longint;
  var i, nr: longint;
begin
  nr := 0;
  for i := 1 to uodega-1 do
    if d[Q[nr]] > d[Q[i]]
       then nr := i;
  min := nr;
end; { min }

procedure Dijkstra (s: longint; var d: Tvmas);
{ randa trumpiausià atstumà svoriniame grafe nuo s iki visø kitø virðûniø }
  var nr, uodega, u, v, laikas: longint;
begin
  Inicializuoti (s, G);
  uodega := 0;
  for v := 0 to K do
    i_eile (v, uodega);
  while uodega <> 1 do
    begin
      nr := min (uodega);
      u := Q[nr];
      is_eiles (nr, uodega);
      if d[u] = maxlongint
         then exit;
      for v := 0 to K do
        if g[u, v]
           then begin
                  if (u div MXA) = (v div MXA)
                     then laikas := t1
                     else laikas := t2;
                  if d[v] > d[u] + laikas
                     then begin
                             d[v] := d[u] + laikas;
                             tv[v] := u;
                           end;
                 end
      end;
end; { Dijkstra }


  procedure skaityti (var K, NS, t, t1, t2, s: longint;
                      var g: Tlmas; var nyk: Tvmas);
    var f: text;
        num1, num2, i, j, P, N, km, a1, k1, a2, k2: longint;
  begin
   assign (f, PRF);
   reset (f);
   readln (f, N, NS, P);
   K := N * MXK;
   for i := 1 to N do
     read (f, km); { kambariø skaièiaus nenaudosime }
   readln (f, a1, k1);
   s := (a1-1)*MXA + k1-1;
   readln (f, t, t1, t2);
   { inicializuojamas grafas }
   for i := 0 to K do
     for j := 0 to K do
       g[i, j] := false;
   for i := 1 to NS do
     begin
       readln (f, a1, k1);
       nyk[i] := (a1-1)*MXA + k1-1;
      end;
   for i := 1 to P do
     begin
       readln (f, a1, k1, a2, k2);
       num1 := (a1-1)*MXA + k1-1;
       num2 := (a2-1)*MXA + k2-1;
       g[num1, num2] := true;
       g[num2, num1] := true;
     end;
   close (f);
  end;   { skaityti }

  function skaiciuoti: longint;
  { kiek nykðtukø suspës }
    var i, spes: longint;
  begin
    spes := 0;
    for i := 1 to NS do
      if d[nyk[i]]<= t
         then spes := spes + 1;
    skaiciuoti := spes;
  end; { skaièiuoti }

  procedure rasyti (spes: longint);
    var f: text;
        i: longint;
  begin
    assign (f, RZF);
    rewrite (f);
    writeln (f, spes);
    for i := 1 to NS do
      if d[nyk[i]]<=t
         then writeln (f, i);
   close (f);
  end; { raðyti }

  var s: longint; { iðëjimas ið namo }
      spes: longint;
begin
  skaityti (K, NS, t, t1, t2, s, g, nyk);
  Dijkstra (s, d);
  spes := skaiciuoti;
  rasyti (spes);
end.
