← Home
```go
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	const INF = 1 << 60
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	readInt := func() int {
		scanner.Scan()
		var x int
		fmt.Sscan(scanner.Text(), &x)
		return x
	}
	
	a := readInt()
	n := readInt()
	m := readInt()
	
	isRain := make([]bool, a)
	for i := 0; i < n; i++ {
		l := readInt()
		r := readInt()
		for x := l; x < r; x++ {
			isRain[x] = true
		}
	}
	
	minUmbrella := make([]int, a+1)
	for i := range minUmbrella {
		minUmbrella[i] = INF
	}
	for i := 0; i < m; i++ {
		x := readInt()
		p := readInt()
		if p < minUmbrella[x] {
			minUmbrella[x] = p
		}
	}
	
	cur := make(map[int]int)
	cur[0] = 0
	
	for i := 0; i < a; i++ {
		next := make(map[int]int)
		for w, cost := range cur {
			candidates := []int{w}
			if minUmbrella[i] != INF && (w == 0 || minUmbrella[i] < w) {
				candidates = append(candidates, minUmbrella[i])
			}
			
			for _, nw := range candidates {
				if isRain[i] {
					if nw == 0 {
						continue
					}
					nc := cost + nw
					if val, ok := next[nw]; !ok || nc < val {
						next[nw] = nc
					}
				} else {
					nc := cost + nw
					if val, ok := next[nw]; !ok || nc < val {
						next[nw] = nc
					}
					if val, ok := next[0]; !ok || cost < val {
						next[0] = cost
					}
				}
			}
		}
		cur = next
		if len(cur) == 0 {
			fmt.Println(-1)
			return
		}
	}
	
	ans := INF
	for _, cost := range cur {
		if cost < ans {
			ans = cost
		}
	}
	if ans == INF {
		fmt.Println(-1)
	} else {
		fmt.Println(ans)
	}
}
```