package main import ( "bufio" "fmt" "os" "strconv" ) func min(x, y int) int { if x < y { return x } return y } func main() { var ( a uint32 b uint32 x uint32 ) a = uint32(readInt()) b = uint32(readInt()) x = uint32(readInt()) N := readInt() p0 := 0 p1 := 0 bs0 := 0 ws0 := 0 bs1 := 0 ws1 := 0 for i := 0; i < N; i++ { x = a*x + b p0 += int(x%6) + 1 if p0&1 == 1 { bs0++ } else { ws0++ } x = a*x + b p1 += int(x%6) + 1 if p1&1 == 1 { bs1++ } else { ws1++ } } fmt.Printf("%d %d \n", min(bs0, ws0), min(bs1, ws1)) } const ( ioBufferSize = 1 * 1024 * 1024 // 1 MB ) var stdinScanner = func() *bufio.Scanner { result := bufio.NewScanner(os.Stdin) result.Buffer(make([]byte, ioBufferSize), ioBufferSize) result.Split(bufio.ScanWords) return result }() func readString() string { stdinScanner.Scan() return stdinScanner.Text() } func readInt() int { result, err := strconv.Atoi(readString()) if err != nil { panic(err) } return result } func readInts(n int) []int { result := make([]int, n) for i := 0; i < n; i++ { result[i] = readInt() } return result }