← Home
package main

import (
	"bufio"
	"os"
	"strconv"
)

const INF int32 = 1e9

type Node struct {
	minA int32
	maxB int32
	viol bool
}

var tree []Node

func build(node int, l int, r int) {
	tree[node].minA = INF
	tree[node].maxB = -INF
	tree[node].viol = false
	if l == r {
		return
	}
	mid := (l + r) / 2
	build(2*node, l, mid)
	build(2*node+1, mid+1, r)
}

func update(node int, l int, r int, y int, minA int32, maxB int32) {
	if l == r {
		tree[node].minA = minA
		tree[node].maxB = maxB
		tree[node].viol = minA <= maxB
		return
	}
	mid := (l + r) / 2
	if y <= mid {
		update(2*node, l, mid, y, minA, maxB)
	} else {
		update(2*node+1, mid+1, r, y, minA, maxB)
	}

	left := tree[2*node]
	right := tree[2*node+1]

	tree[node].minA = left.minA
	if right.minA < tree[node].minA {
		tree[node].minA = right.minA
	}

	tree[node].maxB = left.maxB
	if right.maxB > tree[node].maxB {
		tree[node].maxB = right.maxB
	}

	tree[node].viol = left.viol || right.viol || (left.minA <= right.maxB)
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	const maxCapacity = 10 * 1024 * 1024
	buf := make([]byte, maxCapacity)
	scanner.Buffer(buf, maxCapacity)

	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	scanInt := func() int {
		scanner.Scan()
		res, _ := strconv.Atoi(scanner.Text())
		return res
	}

	scanner.Scan()
	if scanner.Text() == "" {
		return
	}
	n := func() int {
		res, _ := strconv.Atoi(scanner.Text())
		return res
	}()
	m := scanInt()
	q := scanInt()

	_ = n

	tree = make([]Node, 4*m+1)
	build(1, 1, m)

	minA := make([]int32, m+1)
	maxB := make([]int32, m+1)
	for i := 1; i <= m; i++ {
		minA[i] = INF
		maxB[i] = -INF
	}

	for k := 0; k < q; k++ {
		i := scanInt()
		j := scanInt()

		var x, y int
		if i%2 != 0 {
			x = (i + 1) / 2
			y = (j + 1) / 2
			if int32(x) < minA[y] {
				minA[y] = int32(x)
				update(1, 1, m, y, minA[y], maxB[y])
			}
		} else {
			x = i / 2
			y = j / 2
			if int32(x) > maxB[y] {
				maxB[y] = int32(x)
				update(1, 1, m, y, minA[y], maxB[y])
			}
		}

		if tree[1].viol {
			out.WriteString("NO\n")
		} else {
			out.WriteString("YES\n")
		}
	}
}