← Home
package main

import (
	"fmt"
	"os"
)

func main() {
	buf := make([]byte, 8192)
	var pos, total int
	nextChar := func() byte {
		if pos >= total {
			var err error
			total, err = os.Stdin.Read(buf)
			if err != nil || total == 0 {
				return 0
			}
			pos = 0
		}
		b := buf[pos]
		pos++
		return b
	}

	nextInt := func() int64 {
		b := nextChar()
		for b <= ' ' && b != 0 {
			b = nextChar()
		}
		if b == 0 {
			return 0
		}
		var res int64
		for b > ' ' {
			res = res*10 + int64(b-'0')
			b = nextChar()
		}
		return res
	}

	n := nextInt()
	if n == 0 {
		return
	}
	m := int(nextInt())
	dx := nextInt()
	dy := nextInt()

	count := make([]int, n)
	firstX := make([]int64, n)
	firstY := make([]int64, n)

	var maxC int64 = 0
	var maxCount int = -1

	for i := 0; i < m; i++ {
		x := nextInt()
		y := nextInt()

		c := (y*dx - x*dy) % n
		if c < 0 {
			c += n
		}

		if count[c] == 0 {
			firstX[c] = x
			firstY[c] = y
		}
		count[c]++

		if count[c] > maxCount {
			maxCount = count[c]
			maxC = c
		}
	}

	fmt.Printf("%d %d\n", firstX[maxC], firstY[maxC])
}