#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
long long read() {
  bool f = 0;
  long long x = 0;
  char c = getchar();
  while (c < '0' || '9' < c) {
    if (c == '-') f = 1;
    c = getchar();
  }
  while ('0' <= c && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  return !f ? x : -x;
}
const int MAXN = 50000;
const int INF = 0x3f3f3f3f;
long long K;
int n, m, Mod, s[MAXN + 5];
inline int Add(int x, const int &y) {
  x += y;
  return x >= Mod ? x - Mod : x;
}
inline int Mul(long long x, const int &y) {
  x *= y;
  return x >= Mod ? x % Mod : x;
}
pair<long long, int> mo[MAXN + 5];
struct Matrix {
  int r, c, m[2][2];
  inline int *operator[](int x) { return m[x]; }
  inline Matrix operator*(Matrix &B) const {
    Matrix C;
    C.r = r, C.c = B.c;
    if (r == 1) {
      C[0][0] = Add(Mul(m[0][0], B[0][0]), Mul(m[0][1], B[1][0]));
      C[0][1] = Add(Mul(m[0][0], B[0][1]), Mul(m[0][1], B[1][1]));
      return C;
    }
    C[0][0] = C[0][1] = C[1][0] = C[1][1] = 0;
    for (int k = 0; k < c; k++)
      for (int i = 0; i < r; i++)
        for (int j = 0; j < B.c; j++)
          C[i][j] = Add(C[i][j], Mul(m[i][k], B[k][j]));
    return C;
  }
  inline void Init(int R, int C) {
    r = R, c = C, memset(m, 0, sizeof(m));
    return;
  }
  void Print() {
    puts("----");
    for (int i = 1; i <= r; i++, puts(""))
      for (int j = 1; j <= c; j++) printf("%d ", m[i][j]);
    return;
  }
} A, f[MAXN + 5][61], B[MAXN + 5], Tmp;
inline void Cal(long long &x, long long y) {
  if (!y) return;
  long long d = y - x;
  for (int j = 0; d >> j; j++)
    if ((d >> j) & 1) A = A * f[x % n][j], x = x + (1ll << j);
  x = y;
  return;
}
int main() {
  K = read(), Mod = read();
  n = read();
  for (int i = 0; i < n; i++) s[i] = Add(read(), 0);
  s[n] = s[0];
  for (int i = 0; i < n; i++) {
    B[i].Init(2, 2);
    B[i][1][0] = 1;
    B[i][0][1] = s[i];
    B[i][1][1] = s[i + 1];
    f[i][0] = B[i];
  }
  for (int j = 1; (1ll << j) <= K; j++)
    for (int i = 0; i < n; i++)
      f[i][j] = f[i][j - 1] * f[(i + (1ll << (j - 1))) % n][j - 1];
  m = read();
  for (int i = 1; i <= m; i++) mo[i].first = read(), mo[i].second = read();
  sort(mo + 1, mo + m + 1);
  A.Init(1, 2);
  A[0][0] = 0, A[0][1] = 1;
  long long nw = 0;
  int lst = 0;
  for (int i = 1; i <= m && mo[i].first <= K; i++) {
    lst = i;
    if (nw < mo[i].first) {
      Cal(nw, mo[i].first - 1);
      Tmp.Init(2, 2);
      Tmp[1][0] = 1;
      if (mo[i - 1].first + 1 == mo[i].first)
        Tmp[0][1] = mo[i - 1].second;
      else
        Tmp[0][1] = s[(mo[i].first - 1 + n) % n];
      Tmp[1][1] = mo[i].second;
      A = A * Tmp, nw++;
    }
    Tmp[0][1] = mo[i].second;
    if (mo[i].first + 1 == mo[i + 1].first)
      Tmp[1][1] = mo[i + 1].second;
    else
      Tmp[1][1] = s[(mo[i].first + 1) % n];
    A = A * Tmp, nw++;
  }
  if (nw < K) {
    if (lst && mo[lst].first == nw) {
      Tmp.Init(2, 2);
      Tmp[1][0] = 1;
      Tmp[0][1] = mo[lst].second;
      Tmp[1][1] = s[(mo[lst].first + 1) % n];
      A = A * Tmp, nw++;
    }
  }
  Cal(nw, K);
  printf("%d\n", A[0][0]);
  return 0;
}
