def solve(dp,u,t,d,i,tl)
    return dp[d][i] if dp[d][i] != -1
    return dp[d][i] = 0 if d == 100
    return dp[d][i] = Float::INFINITY if u[d] < t[i]
    return dp[d][i] = [solve(dp, u, t, d+1, (i+1)%tl, tl), 1 + solve(dp, u, t, d+1, 0, tl)].min
end
loop do
    tl = gets.to_i
    break if tl == 0
    t = gets.split.map(&:to_i)
    n = gets.to_i
    u = Array.new(100, Float::INFINITY)
    n.times do
        int = gets.split.map(&:to_i)
        u[int[0] - 1] = int[1] if int[1] < u[int[0] - 1]
    end
    dp = Array.new(101).map{Array.new(33,-1)}
    puts solve(dp,u,t,0,0,tl)
end