package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	n := nextInt()
	m := nextInt()
	x := make([]int, n)
	for i := 0; i < n; i++ {
		x[i] = nextInt()
	}
	y := make([]int, m)
	for i := 0; i < m; i++ {
		y[i] = nextInt()
	}

	var xDiff, yDiff int
	if x[0] < 0 {
		xDiff = x[len(x)-1] + abs(x[0])
	} else {
		xDiff = x[len(x)-1] - x[0]
	}
	if y[0] < 0 {
		yDiff = y[len(y)-1] + abs(y[0])
	} else {
		yDiff = y[len(y)-1] - y[0]
	}

	fmt.Println(xDiff, yDiff)
	fmt.Println(xDiff * yDiff * 4 % (int(math.Pow10(9)) + 7))
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

// ---------- Util.
