package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func Scanner() string { sc.Scan() return sc.Text() } func main() { buf := make([]byte, 0) sc.Buffer(buf, 100000007) sc.Split(bufio.ScanWords) n, _ := strconv.Atoi(Scanner()) m, _ := strconv.Atoi(Scanner()) k, _ := strconv.Atoi(Scanner()) mark := Scanner() ver := make([]int, n) side := make([]int, m) for i := 0; i < m; i++ { side[i], _ = strconv.Atoi(Scanner()) } for i := 0; i < n; i++ { ver[i], _ = strconv.Atoi(Scanner()) } ans := 0 for i := 0; i < n; i++ { for j := 0; j < m; j++ { if mark == "+" { ans += side[j] + ver[i] } else { ans += side[j] * ver[i] } } } fmt.Println(ans % k) }