import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    const X = 101;
    const INF = int.max / 4;

    int[] T;
    int[] P;
    bool input() {
        int t; scanf("%d\n", &t);
        if (t == 0) return false;
        T = readln.chomp.split(" ").map!(to!int).array;
        int N; scanf("%d\n", &N);
        P = new int[X];
        P[] = INF;
        foreach (i; 0 .. N) {
            int D, M; scanf("%d %d\n", &D, &M);
            P[D] = min(P[D], M);
        }
        return true;
    }

    void solve() {
        auto dp = new int[][](X, T.length);
        foreach (i; 0 .. X) dp[i][] = INF;
        dp[1][0] = 0;
        foreach (i; 2 .. X) {
            dp[i][0] = min(dp[i][0], dp[i - 1][T.length - 1]);
            dp[i][0] = min(dp[i][0], dp[i - 1].reduce!min + 1);
            foreach (j; 1 .. T.length) {
                if (P[i] < T[j]) continue;
                dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
            }
        }
        /*
        foreach (i; 1 .. X) {
            writeln(dp[i].map!((a) => a == INF ? -1 : a));
        }
        */
        writeln(dp[X - 1].reduce!min);
    }

    while (input) solve;
}