import ru.ifmo.testlib.Checker;
import ru.ifmo.testlib.InStream;
import ru.ifmo.testlib.Outcome;

import java.util.Arrays;
import java.util.Comparator;

public class Check implements Checker {


    class Pair implements Comparable<Pair> {
        int a, b;

        Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }

        @Override
        public int compareTo(Pair o) {
            int res = Integer.compare(a, o.a);
            if (res == 0) {
                return Integer.compare(b, o.b);
            } else {
                return res;
            }
        }
    }
    @Override
    public Outcome test(InStream inf, InStream ouf, InStream ans) {
        int n = inf.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = inf.nextInt();
        }
        int m = inf.nextInt();
        int[] b = new int[m];
        for (int i = 0; i < m; i++) {
            b[i] = inf.nextInt();
        }
        int cAns = ouf.nextInt();
        int jAns = ans.nextInt();
        int k = ouf.nextInt();
        if (k < 0 || k > Math.min(n, m)) {
            return new Outcome(Outcome.Type.PE, String.format("incorrect k"));
        }
        Pair[] c = new Pair[k];
        for (int q = 0; q < k; q++) {
            int i, j;
            i = ouf.nextInt();
            j = ouf.nextInt();
            if (i < 1 || i > n) {
                return new Outcome(Outcome.Type.PE, String.format("incorrect i in line #%d", q + 1));
            }
            if (j < 1 || j > m) {
                return new Outcome(Outcome.Type.PE, String.format("incorrect j in line #%d", q + 1));
            }
            c[q] = new Pair(i, j);
            if (a[i - 1] + b[j - 1] < cAns) {
                return new Outcome(Outcome.Type.WA, String.format("a[%d] + b[%d] < %d", i, j, cAns));
            }
            a[i - 1] += b[j - 1];
        }
        Arrays.sort(c);
        for (int i = 1; i < k; i++) {
            if (c[i - 1].a >= c[i].a || c[i - 1].b >= c[i].b) {
                return new Outcome(Outcome.Type.WA, "Incorrect pairs of indexes");
            }
        }
        for (int i = 0; i < n; i++) {
            if (a[i] < cAns) {
                return new Outcome(Outcome.Type.WA, String.format("a[%d] < %d", i + 1, cAns));
            }
        }

        if (cAns < jAns) {
            return new Outcome(Outcome.Type.WA, String.format("expected min: %d, found: %d", jAns, cAns));
        }
        if (cAns > jAns) {
            return new Outcome(Outcome.Type.FAIL, String.format("expected min: %d, found: %d", jAns, cAns));
        }
        return new Outcome(Outcome.Type.OK, String.format("%d", jAns));
    }
}
