------
## 最终结论
```python
def read_input():
    import sys
    input = sys.stdin.read
    data = input().splitlines()
    
    index = 0
    t = int(data[index])
    index += 1
    test_cases = []
    
    for _ in range(t):
        n = int(data[index])
        index += 1
        monsters = list(map(int, data[index].split()))
        index += 1
        m = int(data[index])
        index += 1
        
        heroes = []
        for __ in range(m):
            p, s = map(int, data[index].split())
            heroes.append((p, s))
            index += 1
        
        test_cases.append((n, monsters, m, heroes))
    
    return test_cases

def preprocess_heroes(heroes):
    # Create a dictionary to store the maximum endurance for each power level
    max_endurance = {}
    
    for power, endurance in heroes:
        if power not in max_endurance:
            max_endurance[power] = endurance
        else:
            max_endurance[power] = max(max_endurance[power], endurance)

    # Create a sorted list of powers and their maximum endurance
    sorted_powers = sorted(max_endurance.items())
    
    # Create a list to store the maximum endurance for each power level up to the highest one
    max_endurance_up_to_power = []
    current_max_endurance = 0
    
    for power, endurance in sorted_powers:
        current_max_endurance = max(current_max_endurance, endurance)
        max_endurance_up_to_power.append((power, current_max_endurance))
    
    return max_endurance_up_to_power

def simulate_battles(test_cases):
    results = []
    
    for n, monsters, m, heroes in test_cases:
        # Preprocess the heroes to get the maximum endurance for each power level
        available_heroes = preprocess_heroes(heroes)
        
        current_monster_index = 0
        days = 0
        
        while current_monster_index < n:
            days += 1
            # Find the best hero for the current monster
            monster_power = monsters[current_monster_index]
            chosen_hero_found = False
            
            # Find the hero with enough power to defeat the monster
            for power, endurance in available_heroes:
                if power >= monster_power:
                    # If we found a suitable hero, determine how many monsters can be defeated
                    max_monsters_defeated = min(endurance, n - current_monster_index)
                    current_monster_index += max_monsters_defeated
                    chosen_hero_found = True
                    break
            
            if not chosen_hero_found:
                results.append(-1)
                break
        else:
            results.append(days)
    
    return results

def output_results(results):
    print("\n".join(map(str, results)))

test_cases = read_input()
output_results(simulate_battles(test_cases))
```