import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); int n = Integer.parseInt(sa[0]); int m = Integer.parseInt(sa[1]); int k = Integer.parseInt(sa[2]); sa = br.readLine().split(" "); String s = sa[0]; long[] b = new long[m]; for (int i = 0; i < b.length; i++) { b[i] = Long.parseLong(sa[i + 1]); } long[] a = new long[n]; for (int i = 0; i < a.length; i++) { a[i] = Long.parseLong(br.readLine()); } br.close(); long ans = 0; long suma = 0; for (int i = 0; i < a.length; i++) { suma += a[i]; } long sumb = 0; for (int i = 0; i < b.length; i++) { sumb += b[i]; } suma %= k; sumb %= k; if ("+".equals(s)) { ans = suma * m + sumb * n; } else { ans = suma * sumb; } ans %= k; System.out.println(ans); } }