#include <bits/stdc++.h>
namespace pb_ds {
namespace io {
const int MaxBuff = 1 << 15;
const int Output = 1 << 23;
char BB[MaxBuff], *S = BB, *T = BB;
char Out[Output], *iter = Out;
inline void flush() {
  fwrite(Out, 1, iter - Out, stdout);
  iter = Out;
}
}  // namespace io
template <class Type>
inline Type Read() {
  using namespace io;
  register char ch;
  register Type ans = 0;
  register bool neg = 0;
  while (ch = ((S == T) && (T = (S = BB) + fread(BB, 1, MaxBuff, stdin), S == T)
                   ? 0
                   : *S++),
         (ch < '0' || ch > '9') && ch != '-')
    ;
  ch == '-' ? neg = 1 : ans = ch - '0';
  while (ch = ((S == T) && (T = (S = BB) + fread(BB, 1, MaxBuff, stdin), S == T)
                   ? 0
                   : *S++),
         '0' <= ch && ch <= '9')
    ans = ans * 10 + ch - '0';
  return neg ? -ans : ans;
}
template <class Type>
inline void Print(register Type x, register char ch = '\n') {
  using namespace io;
  if (!x)
    *iter++ = '0';
  else {
    if (x < 0) *iter++ = '-', x = -x;
    static int s[100];
    register int t = 0;
    while (x) s[++t] = x % 10, x /= 10;
    while (t) *iter++ = '0' + s[t--];
  }
  *iter++ = ch;
}
}  // namespace pb_ds
using namespace pb_ds;
using namespace io;
using namespace std;
const int N = 3e5 + 5;
int n, k, q;
int a[N], b[N], c[N];
int sa[N], sb[N];
namespace sub1 {
const int B = 450;
const int M = (1 << 14) + 5;
int ans, tot, flag;
int cnt[B * 3][M], tag[B * 3];
int sum[B];
struct part {
  int sz;
  int L[B], R[B], id[B];
  vector<int> s;
  inline void init() {
    for (int i = 0; i < sz; ++i) R[i / B + 1] = i;
    for (int i = sz; i; --i) L[i / B + 1] = i;
    for (int i = 1; i <= (sz - 1) / B + 1; ++i) id[i] = ++tot;
    for (int i = 1; i < sz; ++i) s[i] ^= s[i - 1];
    for (int i = 0; i < sz; ++i) ++cnt[id[i / B + 1]][s[i]];
  }
  inline void query(int opt) {
    ans += opt * sz;
    for (int i = 1; i <= (sz - 1) / B + 1; ++i)
      ans -= opt * cnt[id[i]][tag[id[i]]];
  }
  inline void upd(int l, int r, int k) {
    int bl = l / B + 1, br = r / B + 1;
    for (int i = bl + 1; i < br; ++i) tag[id[i]] ^= k;
    for (int i = l; i <= R[bl] && i <= r; ++i)
      --cnt[id[bl]][s[i]], s[i] ^= k, ++cnt[id[bl]][s[i]];
    if (bl == br) return;
    for (int i = L[br]; i <= r; ++i)
      --cnt[id[br]][s[i]], s[i] ^= k, ++cnt[id[br]][s[i]];
  }
} p[B];
inline void update(int x) {
  p[x % k].query(-1);
  flag -= (sum[x % k] != 0);
  p[x % k].upd(x / k - (x % k == 0), p[x % k].sz - 1, c[x] ^ sa[x] ^ sb[x]);
  sum[x % k] ^= c[x] ^ sa[x] ^ sb[x];
  flag += (sum[x % k] != 0);
  p[x % k].query(1);
  c[x] = sa[x] ^ sb[x];
}
inline void solve() {
  for (int i = 1; i <= n; ++i)
    p[i % k].s.push_back(c[i]), ++p[i % k].sz, sum[i % k] ^= c[i];
  for (int i = 0; i < k; ++i) flag += (sum[i] != 0);
  for (int i = 0; i < k; ++i) p[i].init(), p[i].query(1);
  if (flag)
    puts("-1");
  else
    printf("%d\n", ans);
  while (q--) {
    char ch = 0;
    while (ch != 'a' && ch != 'b')
      ch = ((S == T) && (T = (S = BB) + fread(BB, 1, MaxBuff, stdin), S == T)
                ? 0
                : *S++);
    int x = Read<int>(), val = Read<int>();
    if (ch == 'a')
      a[x] = val, sa[x] = val ^ a[x - 1], sa[x + 1] = val ^ a[x + 1];
    else
      b[x] = val, sb[x] = val ^ b[x - 1], sb[x + 1] = val ^ b[x + 1];
    update(x), update(x + 1);
    if (flag)
      puts("-1");
    else
      printf("%d\n", ans);
  }
  exit(0);
}
}  // namespace sub1
namespace sub2 {
int ans, flag;
int f[N];
inline int upd(int x, int opt) {
  int sum = 0;
  for (int i = x; i <= n; i += k) sum ^= c[i], ans += opt * (sum != 0);
  return sum;
}
inline void solve() {
  ans = 0;
  for (int i = 0; i < k; ++i) f[i] = upd(i, 1), flag += (f[i] != 0);
  if (flag)
    puts("-1");
  else
    printf("%d\n", ans);
  while (q--) {
    char ch = 0;
    while (ch != 'a' && ch != 'b')
      ch = ((S == T) && (T = (S = BB) + fread(BB, 1, MaxBuff, stdin), S == T)
                ? 0
                : *S++);
    if (ch == 'a') {
      int x = Read<int>(), val = Read<int>();
      upd(x % k, -1), sa[x] = val ^ a[x - 1];
      c[x] = sa[x] ^ sb[x], flag -= (f[x % k] != 0);
      f[x % k] = upd(x % k, 1), flag += (f[x % k] != 0);
      upd((x + 1) % k, -1), sa[x + 1] = val ^ a[x + 1];
      c[x + 1] = sa[x + 1] ^ sb[x + 1], flag -= (f[(x + 1) % k] != 0);
      f[(x + 1) % k] = upd((x + 1) % k, 1), flag += (f[(x + 1) % k] != 0);
      a[x] = val;
    } else {
      int x = Read<int>(), val = Read<int>();
      upd(x % k, -1), sb[x] = val ^ b[x - 1];
      c[x] = sa[x] ^ sb[x], flag -= (f[x % k] != 0);
      f[x % k] = upd(x % k, 1), flag += (f[x % k] != 0);
      upd((x + 1) % k, -1), sb[x + 1] = val ^ b[x + 1];
      c[x + 1] = sa[x + 1] ^ sb[x + 1], flag -= (f[(x + 1) % k] != 0);
      f[(x + 1) % k] = upd((x + 1) % k, 1), flag += (f[(x + 1) % k] != 0);
      b[x] = val;
    }
    if (flag)
      puts("-1");
    else
      printf("%d\n", ans);
  }
  exit(0);
}
}  // namespace sub2
int main() {
  n = Read<int>(), k = Read<int>(), q = Read<int>();
  for (int i = 1; i <= n; ++i) sa[i] = a[i - 1] ^ (a[i] = Read<int>());
  for (int i = 1; i <= n; ++i) sb[i] = b[i - 1] ^ (b[i] = Read<int>());
  ++n, sa[n] = a[n - 1], sb[n] = b[n - 1], a[n] = b[n] = 0;
  for (int i = 1; i <= n; ++i) c[i] = sa[i] ^ sb[i];
  if (1ll * k * k <= n)
    sub1::solve();
  else
    sub2::solve();
  return 0;
}
