#include <bits/stdc++.h>
using namespace std;
const int N = 400005, B = 500;
int a[N], b[N], c[N];
int n, k, Q, ans, GG;
struct data {
  int a[(1 << 14) + 2];
};
vector<data> to[N];
vector<int> v[N], V[N];
void build(int id) {
  int x = (n / k) + (id < n % k) - 1;
  for (int j = id; j <= n; j += k) v[id][j / k] = c[j];
  for (int i = x; i >= 0; i--) {
    v[id][i] ^= v[id][i + 1];
    if (!v[id][i]) ans--;
    if (i / B < to[id].size()) to[id][i / B].a[v[id][i]]++;
  }
  if (v[id][0] && id != k - 1) GG++;
}
void change(int pos, int vv) {
  int id = pos % k;
  pos /= k;
  if ((v[id][0] ^ V[id][0]) && id != k - 1) GG--;
  int bel = pos / B, x = V[id][bel];
  for (int i = (int)(pos); i >= (int)(pos / B * B); i--) {
    if (v[id][i] == x) ans++;
    if (bel < to[id].size()) to[id][bel].a[v[id][i]]--;
    v[id][i] ^= vv;
    if (bel < to[id].size()) to[id][bel].a[v[id][i]]++;
    if (v[id][i] == x) ans--;
  }
  for (int i = (int)(bel - 1); i >= (int)(0); i--) {
    ans += to[id][i].a[V[id][i]];
    V[id][i] ^= vv;
    ans -= to[id][i].a[V[id][i]];
  }
  if ((v[id][0] ^ V[id][0]) && id != k - 1) GG++;
}
int main() {
  scanf("%d%d%d", &n, &k, &Q);
  ans = n;
  for (int i = (int)(0); i <= (int)(n - 1); i++) scanf("%d", &a[i]);
  for (int i = (int)(0); i <= (int)(n - 1); i++) scanf("%d", &b[i]);
  for (int i = (int)(n - 1); i >= (int)(0); i--)
    c[i] = a[i] ^ b[i] ^ a[i + 1] ^ b[i + 1];
  for (int i = (int)(0); i <= (int)(k - 1); i++) {
    v[i].resize(n / k + 3);
    V[i].resize(n / k / B + 3);
    to[i].resize((n / k + 3) / B);
    build(i);
  }
  printf("%d\n", GG ? -1 : ans);
  while (Q--) {
    int p, v;
    char s[10];
    scanf("%s%d%d", s, &p, &v);
    p--;
    if (s[0] == 'a') {
      change(p, v ^ a[p]);
      if (p) change(p - 1, v ^ a[p]);
      a[p] = v;
    } else {
      change(p, v ^ b[p]);
      if (p) change(p - 1, v ^ b[p]);
      b[p] = v;
    }
    printf("%d\n", GG ? -1 : ans);
  }
}
